r - summarise_each deprecated - new summarise_at throws error -
i working following code , data summarize values:
bvsubcount.subset %>% group_by(bv.parentbvid) %>% summarise_each(funs(sum), c(`2003`:`2005`)) -> bvsubcount.subset date example:
bvsubcount.subset <- setnames(data.frame(c("at", "de", "it"), c("id1", "id1", "id2"),1:3,5:7,3:5), c("bv.sub.country.iso", "bv.parentbvid", 2003:2005)) so far, worked fine, since getting following warning:
`summarise_each()` deprecated. use `summarise_all()`, `summarise_at()` or `summarise_if()` instead. map `funs` on selection of variables, use `summarise_at()` if use summarise_at, however, using following code, error error:
bvsubcount.subset %>% group_by(bv.parentbvid) %>% summarise_at(funs(sum), c(`2003`:`2005`)) -> bvsubcount.subset .vars` must character/numeric vector or `vars()` object, not list how can use new summarise functions avoid warning , still use similar code structure?
as error suggesting .vars must character vector of variable names, can try this:
bvsubcount.subset %>% + group_by(bv.parentbvid) %>% + summarise_at(.vars = c("2003","2004","2005"),.funs = sum) -> bvsubcount.subset if don't want explicitly mention each numeric column name replace c("2003","2004","2005") as.character(2003:2005)
Comments
Post a Comment