[R] Need to append vector to all levels of nested list WITHOUT a loop
Johannes Reichl
reichl at energieinstitut-linz.at
Mon Jun 18 15:54:07 CEST 2012
Hi everyone,
I have a list betaMoments with 2 levels, e.g.
> beta1 = list(
+ m = 4,
+ v = 5
+ )
> beta2 = list(
+ m = 6,
+ v = 7
+ )
>
> betaMoments = list()
> betaMoments[[1]] = beta1
> betaMoments[[2]] = beta2
and I have a matrix Names which has the same number of lines as the
list has first level elements (here 2; beta1 and beta2). Now I need to
make every line of Names (e.g. Names[1,] = c(2,3,4)) to become an
element of the corresponding list element. For example, calling
betaMoments[[1]] shall return
> betaMoments[[1]]
$m
[1] 4
$v
[1] 5
$line
[1] c(2,3,4) ... thats Names[1,]
I can not do it with a loop since I need to execute this list
construction way too often. So I need a speedy solution.
Would be great if someone could help me, this really keeps me away from
resolving the true issues.
Regards, Johannes
********************************************************************
Dr. Johannes Reichl
Project Manager
Energy Institute at the Johannes Kepler University Linz
Altenberger Straße 69
A-4040 Linz
Tel.: +43-732-2468-5652
Fax: +43-732-2468-5651
Email: reichl at energieinstitut-linz.at
Web: www.energieinstitut-linz.at
www.energyefficiency.at
More information about the R-help
mailing list