Creating a table for frequency analysis results in R

前端 未结 3 807
执笔经年
执笔经年 2020-12-21 19:21

I need to create a table of a certain type and based on a certain template.

This is my data:

df = structure(list(group = c(1L, 1L, 2L, 2L, 2L, 3L, 3L,          


        
3条回答
  •  不思量自难忘°
    2020-12-21 19:45

    you want the fractions, together with the total numbers? Try:

    n=table(df$degree,df$group)
    df=as.data.frame(cbind(n/colSums(n)*100,n))
    

提交回复
热议问题