[R] is there an inverse method for table()?

Gabor Grothendieck ggrothendieck at gmail.com
Tue Mar 9 17:05:52 CET 2010


Try

  as.data.frame.table(mytable)

On Tue, Mar 9, 2010 at 10:58 AM, vincent laperriere
<vincent_laperriere at yahoo.fr> wrote:
> Hi,
>
> In R, I know the method table(), which builds a contingency table of the counts y at each level for the factor x.
> But I would like to know what is the inverse method of table(), if it exists, to obtain the vector z, from the two vectors x and y?
>
> x <- (86,  90,  94,  98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 142, 146, 150, 154, 158, 162, 166, 170, 174)
> y <- c(2, 5, 10, 17, 26, 60, 94, 128, 137, 128, 77, 68, 65, 60, 51, 26, 17, 9, 5, 2, 3, 7, 3)
>
>> z
>   [1]  86  86  90  90  90  90  90  94  94  94  94  94  94  94  94  94  94  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98 102 102 102 102 102
>  [40] 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102...
>  [976] ...170 170 170 170 170 170 170 174 174 174
>
> If such a method does not exist, what code should I type to obtain the complete series quickly?
>
> Thank you for your help.
> I use version 2.10-1 2009-08-24 for Mac OS.
>
> Vincent Laperrière.
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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