Re: [R] list of list objects

From: jim holtman <jholtman_at_gmail.com>
Date: Fri, 21 Nov 2008 15:26:24 -0500

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?

______________________________________________
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.
Received on Fri 21 Nov 2008 - 20:28:22 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 21 Nov 2008 - 20:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive