RMySQL and factors
How about:
getrace <- function(connection) {
sql <- "SELECT race FROM PATIENT"
rs <- dbGetQuery(connection, sql)
rs$trace <- factor(rs$trace)
class(rs$race)
}
At 1:50 AM -0800 2/3/05, James Bullard wrote:
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
_______________________________________________ R-sig-DB mailing list -- R Special Interest Group R-sig-DB at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-db
-------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA