|
|
@ -18,8 +18,8 @@ perc(v) |
|
|
|
# It can be used with dplyr tables |
|
|
|
library(tidyverse) |
|
|
|
df<-data.frame("X"=c("A","A","B","B"), "Y"=v) |
|
|
|
df \%>\% group_by(X) \%>\% summarise(Y=perc(Y)) |
|
|
|
df \%>\% mutate(Y=perc(Y)) |
|
|
|
|
|
|
|
# Or it can be under 1 |
|
|
|
df \%>\% group_by(X) \%>\% summarise(Y=perc(Y, per100=F)) |
|
|
|
df \%>\% mutate(Y=perc(Y, per100=F)) |
|
|
|
} |