[R-sig-DB] RMySQL and factors

James Bullard bu||@rd @end|ng |rom berke|ey@edu
Thu Feb 3 10:50:42 CET 2005


I have just started using the RMySQL package and things are working out
well, but I would like to know if it is possible to return a data.frame
from dbGetQuery with class(dta$race) => factor rather than
class(dta$race) => character. I want to use glm on the resultant data,
but I cant figure out how to change the columns without effort. 

Currently what I do is write the dta to a local file and then re-read it
at which point the columns is of class factor.

Thanks in advance, The code I am using to get the data is:

getrace <- function(connection) {
  sql <- "SELECT race FROM PATIENT"
  rs <- dbGetQuery(connection, sql)

  class(rs$race)  
}

which returns "character" 


Jim




More information about the R-sig-DB mailing list