From: Auston_Wei at mdanderson.org
Hi, list,
suppose i have such a data frame:
trash <-
data.frame(cbind(seq(1:5),c('a','a','b','a','b'),c('b','a','b'
,'b','a')))
names(trash) <- c('age','typeI','typeII')
and I want to change all 'a's to be 0 and 'b's to be 1.
temp <- as.matrix(trash)
temp[temp=='a'] <- 0
temp[temp=='b'] <- 1
temp <- data.frame(temp)
the problem was that temp$typeI and temp$typeII were still factors,
whereas I want numeric type. How can I make it?
Thanks,
Auston
[[alternative HTML version deleted]]