chi_table <-
survey_data %>%
group_by(birthmonth) %>%
ungroup()
summarise(
observed = n(),
expected = totaln/12,
diff = observed-expected,
sq_diff = diff^2,
std_sq_diff = sq_diff / expected
)
chi_table
I am trying to get R to create a tibble for this, but it keeps having errors. First it said that summarise was an ungrouping output and to override with .groups
, but that didn't work so I put ungroup before summary and now it is saying that n() can only be used inside dplyr verbs even though it is in one, summarise. Can someone please help me.