Thank you very much. It is working on Character variables (like Gender). It doesn't on numeric ones. I've added Year
response.data <- data.frame(
A_Top2 = c(NA, 0, 100, 0, 0, 0, 0, 0, 0, 0, 100, 100, 0, NA),
B_Top2 = c(0, 0, 100, 100, 0, 0, 0, 0, 100, 0, 0, 0, 100, 100),
C_Yes = c(NA, 0, 0, 100, 100, 0, 0, NA, 0, 0, 0, 0, 100, 100),
D_Yes = c(0, 0, 0, 100, 0, 100, 0, 0, 100, 0, 0, 0, 100, NA),
Year = c(2020, 2020, 2019, 2018, 2020, 2019,2020, 2020, 2019, 2018, 2020, 2019,NA, 2021),
URN = as.factor(c("aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg",
"hhh", "iii", "jjj", "kkk", "lll", "mmm", "nnn")),
Gender = as.factor(c("Male", "Male", "Male", "Male", "Male", "Male",
"Female", "Female", "Female", "Female", "Female",
"Female", "Male", "Male"))
)
result <- response.data %>%
bind_rows(mutate(.data = .,
Year = "Total")) %>%
group_by(Year) %>%
summarise_at(.vars = vars(ends_with(match = "Top2"), ends_with(match = "Yes")),.funs = list(Aver = ~mean(.,na.rm=TRUE),
Count = ~sum(!is.na(.))))
result
but the function is not working.
I have this error
Error: Can't combine `..1$Year` <double> and `..2$Year` <character>.
Can you help please?