Now I am trying to create a sunbrust plot for the number of births with the inner ring equals to Q1, Q2, Q3 and Q4, the middle ring equals to months and the outer most ring equals to week of the day.
My data is from "https://raw.githubusercontent.com/fivethirtyeight/data/master/births/US_births_2000-2014_SSA.csv"
briths$quarter = case_when(briths$month < 4 ~ "Q1",
briths$month < 7 ~ "Q2",
briths$month < 10 ~ "Q3",
briths$month > 9 ~"Q4")
briths$week = ceiling(briths$date_of_month / 7)
briths$week = paste("M",briths$month,"W",briths$week)
bind_rows(
briths %>%
group_by(week)%>%
summarize(births = sum(births))%>%
select(children = week, parents = month, births = births),
briths %>%
group_by(month) %>%
summarize(births = sum(births)) %>%
transmute(children = month, parents = quarter, births = births),
briths %>%
group_by(quarter) %>%
summarize(births = sum(births)) %>%
transmute(children = quarter, parents = "", births = births)
) %>%
plot_ly(
ids = ~children,
labels = ~children,
parents = ~parents,
values = ~births,
type = "sunburst",
branchvalues = "total")
I get the error: Error: week
and month
must evaluate to column positions or names, not a function.