[R] Creating a model.matrix with a logical data matrix
ehud cohen
ehudco.list at gmail.com
Thu Apr 23 10:49:17 CEST 2009
Hi,
I'm trying to create a model.matrix (or use lm, which result in the
same issue), using a logical data matrix.
When I use a numerical matrix, I can do:
numeric_mat<-matrix(c(1,2,3,4),c(2,2))
model.matrix(~numeric_mat)
and it works well.
When I use logical matrix:
logic_mat<-matrix(c(TRUE,FALSE,FALSE,TRUE),c(2,2))
#The following works:
model.matrix(~logic_mat[,1]+logic_mat[,2])
#but this fails:
model.matrix(~logic_mat)
Any hint?
Thanks, Ehud
More information about the R-help
mailing list