column of a list

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

column of a list

Thomas Steiner
I have a list of (same type) lists. I want to retrieve the same
entries of all my objects in the outer list.
eg:
a<-list("2006-01-23"=list(r=5,s=c(7,12,12,11,4)),
"2006-01-24"=list(r=6,s=c(3,8,8,9,12)))
a[][["s"]]

gives NULL, but I am looking for all the s-vectors in order to plot
and compare them (e changes to f in a day).
Thomas

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: column of a list

Sean Davis



On 1/24/06 8:21 AM, "Thomas Steiner" <[hidden email]> wrote:

> I have a list of (same type) lists. I want to retrieve the same
> entries of all my objects in the outer list.
> eg:
> a<-list("2006-01-23"=list(r=5,s=c(7,12,12,11,4)),
> "2006-01-24"=list(r=6,s=c(3,8,8,9,12)))
> a[][["s"]]
>
> gives NULL, but I am looking for all the s-vectors in order to plot
> and compare them (e changes to f in a day).

This may not be the best solution, but:

 lapply(a,function(x) {x$s})

will get your answer, I think.

Sean

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: column of a list

Gábor Csárdi-2
In reply to this post by Thomas Steiner
> lapply(a, "[[", "s")
$"2006-01-23"
[1]  7 12 12 11  4

$"2006-01-24"
[1]  3  8  8  9 12

This is what you need?

G.

On Tue, Jan 24, 2006 at 02:21:18PM +0100, Thomas Steiner wrote:

> I have a list of (same type) lists. I want to retrieve the same
> entries of all my objects in the outer list.
> eg:
> a<-list("2006-01-23"=list(r=5,s=c(7,12,12,11,4)),
> "2006-01-24"=list(r=6,s=c(3,8,8,9,12)))
> a[][["s"]]
>
> gives NULL, but I am looking for all the s-vectors in order to plot
> and compare them (e changes to f in a day).
> Thomas
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

--
Csardi Gabor <[hidden email]>    MTA RMKI, ELTE TTK

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: column of a list

Dimitris Rizopoulos
In reply to this post by Thomas Steiner
probably you need:

sapply(a, "[[", "s")


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm



----- Original Message -----
From: "Thomas Steiner" <[hidden email]>
To: <[hidden email]>
Sent: Tuesday, January 24, 2006 2:21 PM
Subject: [R] column of a list


>I have a list of (same type) lists. I want to retrieve the same
> entries of all my objects in the outer list.
> eg:
> a<-list("2006-01-23"=list(r=5,s=c(7,12,12,11,4)),
> "2006-01-24"=list(r=6,s=c(3,8,8,9,12)))
> a[][["s"]]
>
> gives NULL, but I am looking for all the s-vectors in order to plot
> and compare them (e changes to f in a day).
> Thomas
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: column of a list

Jacques VESLOT
In reply to this post by Thomas Steiner
lapply(a,"[[","s")

Thomas Steiner a écrit :

>I have a list of (same type) lists. I want to retrieve the same
>entries of all my objects in the outer list.
>eg:
>a<-list("2006-01-23"=list(r=5,s=c(7,12,12,11,4)),
>"2006-01-24"=list(r=6,s=c(3,8,8,9,12)))
>a[][["s"]]
>
>gives NULL, but I am looking for all the s-vectors in order to plot
>and compare them (e changes to f in a day).
>Thomas
>
>______________________________________________
>[hidden email] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>  
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html