No, that''s basically the solution I had already come up with (see the
last line of code from my original post)
but, Yes, I''m thinking this might be the simplest way (even though it
might not scale well to millions of elements )
On Dec 31, 1:17?pm, Dennis Murphy <djmu... at gmail.com>
wrote:> Hi,
>
> Is this what you wanted?
>
> untable <- function(tab) rep(names(tab), as.vector(tab))
> lapply(my.table.list, untable)
> $x
> [1] "a" "a" "b" "b" "c"
>
> $y
> [1] "a" "a" "b" "c" "d"
"d"
>
> $z
> [1] "c" "d" "d"
>
> HTH,
> Dennis
>
>
>
> On Thu, Dec 31, 2009 at 12:37 PM, david.schruth <dschr... at
gmail.com> wrote:
> > Hello,
>
> > I''m trying to construct an overall summary table from a list
of
> > tables.
>
> > my.list <-
list(x=c(''a'',''b'',''a'',''b'',''c''),
y=c
> >
(''a'',''d'',''c'',''a'',''b'',''d''),z=c(''d'',''d'',''c''))
> > my.table.list <- lapply(my.list, table)
>
> > normally this might be really easy:
>
> > master.table <- table(unlist(my.list))
>
> > But as it turns out I''m writing a function which allows the
passing of
> > the table list in the form of ''my.table.list'' above
and I don''t have
> > access to the ''my.list'' form. ? Does anybody know of
an elegant way to
> > make ''master.table'' without too ?much code or direct
reconstruction of
> > ''my.list'' ?(e.g. the following line)
>
> > my.list <- lapply(my.table.list, function(x) rep(names(x),x))
>
> > Thanks in advance,
>
> > Dave
>
> > ______________________________________________
> > R-h... 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.
>
> ? ? ? ? [[alternative HTML version deleted]]
>
> ______________________________________________
> R-h... at r-project.org mailing
listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.