[R] Reversing table()

Mark Sharp msharp at txbiomed.org
Fri Mar 17 14:35:09 CET 2017


Kevin,

The short answer is no.

The function table() takes in the vectors provided as arguments, counts the number of occurrences of each category by adding the integer 1L to a bin (one for each category or factor level), and at the end it returns the counts in each bin. Since it does not return the vectors, those values that went into the function do not survive the trip.

Mark
R. Mark Sharp, Ph.D.
msharp at TxBiomed.org





> On Mar 17, 2017, at 7:23 AM, Kevin E. Thorpe <kevin.thorpe at utoronto.ca> wrote:
>
> I am wondering if there is a way to undo the results of table().
>
> For example if you had a table that looked like the result of table(x, y) or
> table(x, y, z) is there a simple/elegant way to reverse the process to get the
> "original" x, y and z vectors?
>
> Thanks,
>
> Kevin
>
> --
> Kevin E. Thorpe
> Head of Biostatistics,  Applied Health Research Centre (AHRC)
> Li Ka Shing Knowledge Institute of St. Michael's Hospital
> Assistant Professor, Dalla Lana School of Public Health
> University of Toronto
> email: kevin.thorpe at utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
>
> ______________________________________________
> 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.

CONFIDENTIALITY NOTICE: This e-mail and any files and/or...{{dropped:10}}



More information about the R-help mailing list