Hallo >From a variable "x" that defines, say, four classes, I would like to define the matrix "mat" of dummy variables indicating the classes, i.e.
x <- c(1,1,1,1,2,2,2,3,3,3,4,4) mat <- matrix(c(1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,0,1, 0,0,0,1), ncol=4, byrow=T) Thank you for your help, Serguei [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.