Table by row with R

前端 未结 4 1508
暗喜
暗喜 2021-01-22 04:19

I would like to tabulate by row within a data frame. I can obtain adequate results using table within apply in the following example:

         


        
4条回答
  •  长发绾君心
    2021-01-22 04:59

    Protect the result by wrapping with list:

    apply(tdf.2[4:nrow(tdf.2),1:nrow(df.2)], 2, 
                  function(x) {list(table(x, useNA = "ifany")) })
    

提交回复
热议问题