Skip to content

Assembling output of table()

2 messages · Sumitrajit Dhar, Rui Barradas

#
Hi folks,

I am struggling with something that should be simple.

Here is my data frame:
head(jData[,1:8])
  x study_id qx_1_v4j qx_1a_v4j qx_1b_v4j qx_2_v4j qx_2a_v4j qx_3_v4j
1 1  MCJ1001        1         1         1        1         1        1
2 2  MCJ1002        1         1         2        1         2        0
3 3  MCJ1003        1         1         1        0        NA        1
4 4  MCJ1004        1         1         2        1         3        0
5 5  MCJ1005        1         1         1        1         1        1
6 6  MCJ1006        1         1         0        1         3        0


I want to run table() on each of the columns and compile the results into a single list/table/whatever works with the first column being the column name. The resulting output will have different numbers of columns per row.

Is this possible?

Regards, 
Sumit
#
Hello,

Maybe something like th following.

lapply(jData, table)

Hope this helps,

Rui Barradas

Em 07-04-2015 15:47, Sumitrajit Dhar escreveu: