Can someone tell me why this isn't working?
me_totals_by_county <- me %>%
group_by(redcap_data_access_group)%>%
summarise(
(alcohol_number_occurences = sum(grepl('alcohol', me_cause, ignore.case = TRUE) | grepl('ethanol', me_cause, ignore.case = TRUE))),
(fentanyl_number_occurences = sum(grepl('alcohol', me_cause, ignore.case = TRUE)))
)
me_totals_by_county
It doesn't give any error, but it fails to produce the expected output:
redcap_data_access_group `(...)`
<chr> <int>
1 c1 0
2 c2 0
3 c3 1
4 c4 0
thank you.
It looks like you have a couple of extra opening parentheses. Try this:
me_totals_by_county <- me %>%
group_by(redcap_data_access_group)%>%
summarise(
alcohol_number_occurences = sum(grepl('alcohol', me_cause, ignore.case = TRUE) | grepl('ethanol', me_cause, ignore.case = TRUE))),
fentanyl_number_occurences = sum(grepl('alcohol', me_cause, ignore.case = TRUE)))
)
me_totals_by_county
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.