[R] "[.data.frame" and lapply
ba208 at exeter.ac.uk
Thu Mar 26 01:09:45 CET 2009
thanks to some off-list replies, I got this to work,
On 25 Mar 2009, at 18:56, baptiste auguie wrote:
> Dear all,
> Trying to extract a few rows for each element of a list of
> data.frames, I'm puzzled by the following behaviour,
>> d <- lapply(1:4, function(i) data.frame(x=rnorm(5), y=rnorm(5)))
>> lapply(d, "[", i= c(1)) # fine, this extracts the first columns
>> lapply(d, "[", j= c(1, 3)) # doesn't do nothing ?!
lapply(d, "[", c(1,3),)
I still wonder why the named arguments can't be used here, though.
>> llply(d, "[", j= c(1, 3)) # same
> Am i misinterpreting the meaning of "j", which I thought was an
> argument of the method "[.data.frame"?
>> function (x, i, j, drop = if (missing(i)) TRUE else length(cols) ==
> Many thanks,
> Baptiste Auguié
> School of Physics
> University of Exeter
> Stocker Road,
> Exeter, Devon,
> EX4 4QL, UK
> Phone: +44 1392 264187
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
School of Physics
University of Exeter
EX4 4QL, UK
Phone: +44 1392 264187
More information about the R-help