Re: [R] How to get to the varable in a list

From: Hank Stevens <HStevens_at_muohio.edu>
Date: Sun 16 Oct 2005 - 21:32:50 EST

Hi Lisa,
Try the following -- there are probably better solutions, but these seem to work.
Hank Stevens
Miami University
Oxford, OH, USA

a <- vector("list",3)
names(a) <- 1:3
a[[1]] <- data.frame(x1=3,x2=1)
a[[2]] <- data.frame(x1=c(3,3),x2=c(2,2))

a[[3]] <- data.frame(x1=c(3,3), x2=c(3,3)) a

unlist(sapply(a, function(x) x$x1 ))
unlist(sapply(a, function(x) x[,1] ))

Lisa Wang wrote:

>Hello,
>
>I have a list "lis" as the following:
>
>$"1"
> x1 x2
>4 3 1
>
>$"2"
> x1 x2
>3 3 2
>5 3 2
>
>$"3"
> x1 x2
>2 3 3
>6 3 3
>
>How do I get the x1 varible? for example ss"1"
>
>
>
>------------------------------------------------------------------------
>
>This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient. Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited. If you have received this e-mail in error, please contact the sender and delete all copies. Opinions, conclusions or other information contained in this e-mail may not be that of the organization.
>
>------------------------------------------------------------------------
>
>______________________________________________
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Oct 16 21:40:46 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:56:06 EST