[R] Create Arrays

Gerrit Eichner Gerrit.Eichner at math.uni-giessen.de
Fri Oct 15 13:49:34 CEST 2010


Hi, Doug,

maybe


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)
columnnumbers <- c(0, 0, 0, 3, 0, 0, 0, 2, 0)

TMP <- lapply( seq( columnnumbers),
                function( i, CN, M) {
                 if( CN[i] == 0) as.matrix( M[, i]) else
                  matrix( -1, nrow( M), CN[i])
                 }, CN = columnnumbers, M = rbind( HH, TT))

do.call( cbind, TMP)



gets close to what you want (after some adaptation, of course).


  HTH  --  Gerrit

---------------------------------------------------------------------
AOR Dr. Gerrit Eichner               Mathematical Institute, Room 212
gerrit.eichner at math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104          Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109        http://www.uni-giessen.de/cms/eichner



More information about the R-help mailing list