I have a data frame like this:
GN SN a b a b a c d e d f d e
I would like the following output:
GN: a SN: 2 b 1 c
GN d SN: 2 e 1 f
In other words I would like to have a sort of table() of the data.frame on the column S.N. First of all I split the data.frame according to $GN, so I have blocks. At this point I’ m not able to have the counting of the elements on column SN according to the split I’ve done. Is the "apply" function a way to do this? And how can I save a general output belonging from split function?
With your data:
We could do:
But if you don’t want all the levels (the
0entries) then we need to drop the empty levels:Writing out the individual tables to a file
This isn’t perfect but at least you can work with it
That gives:
or from the OS: