Hello,
I think I have a mental block when it comes to working with lists. lapply and
sapply appear to do some magical things, but I can't seem to master their usage.
As an example, I would like to convert a column within a list to a matrix, with
the list element corresponding to the new
test - lapply(1:3, function(i) cbind(runif(15), rnorm(15,2)))
sapply(test, [, 16:30)
b
On Jul 22, 2007, at 3:39 PM, [EMAIL PROTECTED] wrote:
Hello,
I think I have a mental block when it comes to working with lists.
lapply and sapply appear to do some magical things, but I can't
seem
oh! and if you want to be less ad-hoc:
sapply(test, function(x) x[,2])
b
On Jul 22, 2007, at 3:50 PM, Benilton Carvalho wrote:
test - lapply(1:3, function(i) cbind(runif(15), rnorm(15,2)))
sapply(test, [, 16:30)
b
On Jul 22, 2007, at 3:39 PM, [EMAIL PROTECTED] wrote:
Hello,
I think I
Very close... Actually it's more like
savecol2=sapply(test, function(x) x[,1])
to get the same matrix as you showed in your for-loop (did you actually want
the first or second column?).
when I have multiple complex lists I am trying to manage...
for this, you can try mapply() which goes