[R] list of list objects
jim holtman
jholtman at gmail.com
Fri Nov 21 21:26:24 CET 2008
Will one of these two solutions work for you:
> x <- list(list(1,2), list(3,4), list(5,6))
> x
[[1]]
[[1]][[1]]
[1] 1
[[1]][[2]]
[1] 2
[[2]]
[[2]][[1]]
[1] 3
[[2]][[2]]
[1] 4
[[3]]
[[3]][[1]]
[1] 5
[[3]][[2]]
[1] 6
>
> lapply(x, "[[", 1)
[[1]]
[1] 1
[[2]]
[1] 3
[[3]]
[1] 5
> lapply(x, '[', 1)
[[1]]
[[1]][[1]]
[1] 1
[[2]]
[[2]][[1]]
[1] 3
[[3]]
[[3]][[1]]
[1] 5
On Fri, Nov 21, 2008 at 3:14 PM, Rajasekaramya <ramya.victory at gmail.com> wrote:
>
> hi there,
>
> I have a list of list objects i need to remove the top layer
>
> [[1]]
> [1].0
> "ABC" "DEF""LMN"
> [1].1
> "WER" "ERT" "TRY"
>
> [[2]]
> [2].0
> "ASD","wer""qwe"
> [2].1
> "wdv""ghj""ggj"
>
> I wanna avoid the top layer...that is [[1]] [[2]] shouldnt be there
> just a simple list is wat i need.
> [1].0
> "ABC" "DEF""LMN"
> [1].1
> "WER" "ERT" "TRY"
> [2].0
> "ASD","wer""qwe"
> [2].1
> "wdv""ghj""ggj"
> kindly let me know hoe to go abt it
>
> regards
> ramya
>
>
> --
> View this message in context: http://www.nabble.com/list-of-list-objects-tp20628759p20628759.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
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list