[R] Filling a logical matrices with values

Paul- paul at aurynia.com
Fri Feb 5 21:38:21 CET 2010


If I understand your question, this may work for you:

dat <- matrix(as.logical(sample(T:F, 30, T)),5,6)
colnames(dat) <- letters[1:6]
rownames(dat) <- paste(letters[1:5],1:5, sep="")

dat1 <- matrix(NA,5,6)
colnames(dat1) <- colnames(dat)
rownames(dat1) <- rownames(dat)
dat1[dat] <- unlist(sapply(apply(dat,2,sum),seq))

-- 
View this message in context: http://n4.nabble.com/Filling-a-logical-matrices-with-values-tp1469365p1470763.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list