Counting unique items in data frame

后端 未结 4 526
予麋鹿
予麋鹿 2020-12-09 00:22

I want a simple count of the number of subjects in each condition of a study. The data look something like this:

subjectid  cond   obser variable
1234                


        
4条回答
  •  盖世英雄少女心
    2020-12-09 00:26

    or, if you like SQL and don't mind installing a package:

    library(sqldf);
    sqldf("select cond, count(distinct subjectid) from dat")
    

提交回复
热议问题