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)))
str(d)
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.
Thanks all,
baptiste
library(plyr)
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"?
args(`[.data.frame`)
function (x, i, j, drop = if (missing(i)) TRUE else length(cols) ==
1)
Many thanks,
baptiste
_____________________________
Baptiste AuguiƩ
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
______________________________________________
[email protected] 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.
_____________________________
Baptiste AuguiƩ
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
______________________________________________
[email protected] 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.