Skip to content
Prev 12375 / 398502 Next

variable number of variables in data frames

Kevin, you can treat data frames as matrices, i.e. you can do

  dat <- matrix(c(2,1,1,1, 1,1,1,1), 2, 4)
  D <- as.data.frame(dat)
  for (i in 1:ncol(D)) 
    D[,i] <- factor(D[,i], 1:2)


Henrik
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._