This looks like a copying issue as you no longer have commas at the end of each line:
chi_table <- survey_data %>%
group_by(birthmonth) %>%
summarise(observed = n(),
expected = totaln/12 # missing comma
diff = observed-expected # missing comma
sq_diff = diff^2 # missing comma
std_sq_diff = sq_diff/expected
)
Without the commas the programme is reading it all as one line, like missing punctuation in a paragraph makes no sense. The error Error: unexpected ')' in " )" is suggesting you are missing an end bracket but that's not what is missing in this case but it's a common thing to miss.
chi_table <- survey_data %>%
group_by(birthmonth) %>%
summarise(observed = n(),
expected = totaln/12,
diff = observed-expected,
sq_diff = diff^2,
std_sq_diff = sq_diff/expected
)