[R] Create Arrays
dpender
d.pender at civil.gla.ac.uk
Fri Oct 15 15:43:07 CEST 2010
Hi Gerrit,
Almost it but I need to insert M[,i] as well as (matrix( -1, nrow( M),
CN[i]) when CN[i] = 0
I know this is not correct but can something like the following be done?
HH <- c(0.88, 0.72, 0.89, 0.93, 1.23, 0.86, 0.98, 0.85, 1.23)
TT <- c(7.14, 7.14, 7.49, 8.14, 7.14, 7.32, 7.14, 7.14, 7.14)
c <- c(0, 0, 0, 2, 0, 0, 0, 2, 0)
TMP <- lapply( seq(c),
function( i, CN, M) {
if( CN[i] == 0) as.matrix( M[, i]) else
(matrix( -1, nrow( M), CN[i]) && as.matrix( M[, i]))
}, CN = c, M = rbind( HH, TT))
do.call( cbind, TMP)
Doug
--
View this message in context: http://r.789695.n4.nabble.com/Create-Arrays-tp2996706p2997060.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list