R calculating grouped frequency table with percentage [duplicate]
问题 This question already has answers here : Calculate Percentage for each time series observations per Group in R (2 answers) Closed 4 years ago . Giving the following data.frame , I would like to calculate the occurance of each variable of VAR and the percentage of these occurence by the grouping variable GROUP : GROUP<-c("G1","G2","G1","G2","G3","G3","G1") VAR<-c("A","B","B","A","B","B","A") d<-data.frame(GROUP,VAR) With table() , I get a nice frequency table, counting the occurences of all