[R] Assembling output of table()

Rui Barradas ruipbarradas at sapo.pt
Tue Apr 7 17:34:49 CEST 2015


Hello,

Maybe something like th following.

lapply(jData, table)

Hope this helps,

Rui Barradas

Em 07-04-2015 15:47, Sumitrajit Dhar escreveu:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list