Message-ID: <1363006000.57420.YahooMailNeo@web142602.mail.bf1.yahoo.com>
Date: 2013-03-11T12:46:40Z
From: arun
Subject: take two columns from a set of lists
In-Reply-To: <CAKL8G3Ex56iESnQSYZu9BzdSkZ=7-AV6mikRoxH2P3uxfGXTug@mail.gmail.com>
You could also do:
simplify2array(x.list)[2,]
#[1] 0.1 3.0
A.K.
----- Original Message -----
From: Jorge I Velez <jorgeivanvelez at gmail.com>
To: ishi soichi <soichi777 at gmail.com>
Cc: r-help <r-help at r-project.org>
Sent: Monday, March 11, 2013 6:57 AM
Subject: Re: [R] take two columns from a set of lists
Is the following that you are looking for?
unlist(lapply(x.list, "[", 2))
HTH,
Jorge.-
On Mon, Mar 11, 2013 at 9:52 PM, ishi soichi <> wrote:
> say I have a matrix and lists like
>
> x <- matrix(c(12.1, 3.44, 0.1, 3, 12, 33.1, 1.1, 23), nrow=2)
>
> x.list <- lapply(seq_len(nrow(x)), function(i) x[i,])
>
> if I want a column of the matrix x, I write
>
> x[, 2]
>
> for example.
>
> But how can I do something similar for a set of lists, x.list, above?
>
> > x.list
> [[1]]
> [1] 12.1? 0.1 12.0? 1.1
>
> [[2]]
> [1]? 3.44? 3.00 33.10 23.00
>
> unlist(x.list)[,2] does not work.
>
>
> Anyone?
>
> ishida
>
>? ? ? ? [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
??? [[alternative HTML version deleted]]
______________________________________________
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.