[R] Transposing the output of 'table'
gunter.berton at gene.com
Sun Oct 6 20:22:24 CEST 2013
But note that this only works for a 2-d table-- which the OP indicated
was what he had; in general, one would have to explicitly permute the
array(table) dimensions, e.g. via aperm() .
On Sun, Oct 6, 2013 at 10:44 AM, Berend Hasselman <bhh at xs4all.nl> wrote:
> On 06-10-2013, at 19:30, Dennis Fisher <fisher at plessthan.com> wrote:
>> R 3.0.1
>> OS X
>> If I execute the command:
>> the output might look like:
>> 1 2
>> 25 336
>> I would like it to appear as:
>> 1 25
>> 2 336
>> I can accomplish this with:
>> TABLE <- table(OBJECT)
>> data.frame(names(TABLE), as.numeric(TABLE))
>> However, I bet that a more clever approach exists? Any takers?
> Have you tried t(table(OBJECT)) ?
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Genentech Nonclinical Biostatistics
More information about the R-help