[R] table of list objects

jim holtman jholtman at gmail.com
Fri Jan 4 01:57:09 CET 2013


try this:

> x <-
+ list(c("q","w"),"r",c("r","w"),c("q","w"))
>  x
[[1]]
[1] "q" "w"

[[2]]
[1] "r"

[[3]]
[1] "r" "w"

[[4]]
[1] "q" "w"

> # create vectors of what is in the list

> x.v <- sapply(x, paste, collapse = ', ')
> table(x.v)
x.v
q, w    r r, w
   2    1    1
>


On Thu, Jan 3, 2013 at 7:50 PM, soon yi <soon.yi at ymail.com> wrote:
> Hi
>
> I have a list such as this
>
> list(c("q","w"),"r",c("r","w"),c("q","w"))
>
> How do i create a table to include the count of groups of terms please?
>
> ie so output is like / similar to
>
> q","w"    "r"     "r","w"
> 2            1            1
>
>
> thanks for any help
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/table-of-list-objects-tp4654601.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.




More information about the R-help mailing list