i'm looking easy way subset df , append column frequency count. suppose have df this:
name ja jn ja jb ja jn
and want have outcome this:
name frequency ja 3 jn 2 jb 1
any suggestion? thank you.
we can use tally
after grouping 'name' dplyr
library(dplyr) df1 %>% group_by(name) %>% tally()
or use table
base r
as.data.frame(table(df1[,1])) # var1 freq #1 ja 3 #2 jb 1 #3 jn 2
Comments
Post a Comment