[R] apply over parallel lists and their elements

Liviu Andronic landronimirc at gmail.com
Sun Sep 12 11:45:38 CEST 2010


On Sun, Sep 12, 2010 at 9:40 AM, Sebastian Gibb <lists at sebastiangibb.de> wrote:
> But I want to do a "sapply" over the "values" vectors.
>
Try multivariate apply. For more on loops and the apply family check
[1]. You might also want to check the plyr package and its
documentation.
Liviu
[1] http://promberger.info/files/rnews-vectorvsloops2008.pdf

> mapply(mean, tree[[1]]$node$values, tree[[2]]$node$values)
 [1]  1  2  3  4  5  6  7  8  9 10
> mapply(mean, tree[[1]]$node$values, tree[[2]]$node$values, SIMPLIFY=F)
[[1]]
[1] 1

[[2]]
[1] 2

[[3]]
[1] 3

[[4]]
[1] 4

[[5]]
[1] 5

[[6]]
[1] 6

[[7]]
[1] 7

[[8]]
[1] 8

[[9]]
[1] 9

[[10]]
[1] 10

>



More information about the R-help mailing list