Here is the specified data frame which i am trying to compute Percentage in group_by function ,
df <- data.frame(Tag = c(1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2),
YPred = c("L1", "L2" ,"L3", "L4", "L5", "L1", "L2", "L3", "L4", "L5"),
Long = c(1004 , 544 , 545 , 282 , 1 ,2068 ,3006 ,3711 ,2342 , 33),
Medium = c(108, 252, 211, 149, 0, 17, 110, 248, 341, 4),
short = c(58, 118, 131, 73, 4, 0, 43, 150, 189,2),
Urgent = c(5, 70, 65, 24 , 5 ,22 ,18, 31 ,96, 2))
Code to achieve Percentage group_by
library(dplyr)
group_by(df, Tag) %>%
mutate_at(.vars = vars(Long:Urgent),
.funs = funs(. / sum(., na.rm = TRUE)))
Getting Error when executing inside reactive function of Shiny
,but i am execute on R console properly.
Error Message
argument ".cols" is missing, with no default