Martijn,
Not the most elegant solution, but . . .
> ccc <- list(list(c(1, 2, 3, 4, 7, 8), c(1, 2, 3, 6, 7, 8)), list(c(1,
2, 3, 4, 6), c(1, 2, 3)))
> vvv <- list(list(c(0.008452287, 0.021192002, 0.021649091, 0.021271986,
0.018899095, 0.018636425), c(0.008443075, 0.019499494, 0.019310736,
0.022038186, 0.017810169, 0.019808354)), list(c(0.008892173,
0.020021322, 0.020639185, 0.018127722, 0.017892154), c(0.008357905,
0.021532654, 0.020787510)))
> vvv <- ccc ### to simplify reading output
> mmm <- matrix(nrow=4, ncol=8)
> mmm
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] NA NA NA NA NA NA NA NA
[2,] NA NA NA NA NA NA NA NA
[3,] NA NA NA NA NA NA NA NA
[4,] NA NA NA NA NA NA NA NA
> mmm[1, ccc[[1]][[1]][[]]] <- vvv[[1]][[1]][[]]
> mmm[2, ccc[[1]][[2]][[]]] <- vvv[[1]][[2]][[]]
> mmm[3, ccc[[2]][[1]][[]]] <- vvv[[2]][[1]][[]]
> mmm[4, ccc[[2]][[2]][[]]] <- vvv[[2]][[2]][[]]
> mmm
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 1 2 3 4 NA NA 7 8
[2,] 1 2 3 NA NA 6 7 8
[3,] 1 2 3 4 NA 6 NA NA
[4,] 1 2 3 NA NA NA NA NA
HTH DaveT.
*************************************
Silviculture Data Analyst
Ontario Forest Research Institute
Ontario Ministry of Natural Resources
Sault Ste. Marie, Ontario, Canada
david.john.thompson@ontario.ca
david.thompson@mnr.gov.on.ca
*************************************
From: Heymans, MW [mailto:mw.heymans@vumc.nl]
Sent: September 20, 2006 06:24 PM
To: s-news
Subject: merging lists?
. . .
I have this list existing of different column numbers:
. . .
and I have this list of different values:
. . .
Now I want to place the values in the exact columns numbers, of a matrix
with 8 columns and 4 rows (consequently some values will be NA).
. . .
|