Count unique values for every column

前端 未结 8 1090
眼角桃花
眼角桃花 2020-12-05 14:13

I would like to return the count of the unique values for every column in a table. For example, if I have the table:

 Testdata <- data.frame(var_1 = c(\"a         


        
8条回答
  •  孤城傲影
    2020-12-05 15:04

    Using the lengthsfunction:

    lengths(lapply(Testdata, unique))
    
    # var_1 var_2 var_3 
    #     1     1     3 
    

提交回复
热议问题