Dropping factors which levels have observations smaller than a specific value-R

后端 未结 4 684
臣服心动
臣服心动 2021-01-16 19:49

Let I have such data frame(df1) with factors:

factor1  factor2  factor3
-------  -------  -------
d        a         x
d        a         x
b        a                


        
4条回答
  •  清酒与你
    2021-01-16 20:35

    We could use Filter

    Filter(function(x) min(nlevels(x))>2, df1)
    

    (based on the results in one of the upvoted posts)

    Or it could be also

    Filter(function(x) min(tabulate(x))>2, df1)
    

提交回复
热议问题