[R] Excel to R

Michael A. Miller mmiller3 at iupui.edu
Mon Jul 17 15:51:49 CEST 2006


>>>>> "Bernardo" == Bernardo Rangel tura <tura at centroin.com.br> writes:

    > Well I use this scripts to import the database

    > require(RODBC)
    > channel <- odbcConnectExcel("f:/teste.xls")
    > data <- sqlFetch(channel, "Sheet1")

Just convert qw to a factor:

require(RODBC)
channel <- odbcConnectExcel("f:/teste.xls")
data <- sqlFetch(channel, "Sheet1")
data$qw <- factor(data$qw)

    > Tha factors variables have tha values enconde this form
    > (1=Yes,2=No and 9 = NA 

If you want to use those levels, you could use

data$qw <- factor(data$qw, levels=c('Yes', 'No', 'NA'))

Mike



More information about the R-help mailing list