[R] RODBC query
Lucke, Joseph F
Joseph.F.Lucke at uth.tmc.edu
Thu May 31 21:43:09 CEST 2007
As a newbie to RODBC (Windows XP), I find that the commands aren't
working quite as expected.
After
Library(RODBC)
I had planned to use the two-step process
myConn = odbcConnectExcel("Dates.xls")
sqlQuery(myConn,"SELECT ID, ADM_DATE, ADM_TIME FROM A") #A is the Excel
spreadsheet name
X = sqlGetResults(myConn, as.is=c(T,T,F))
#2 char variables and 1 integer
odbcClose(myConn)
This doesn't work. Instead the following works:
myConn = odbcConnectExcel("Dates.xls")
X=sqlQuery(myConn,"SELECT ID, ADM_DATE, ADM_TIME FROM A",
as.is=c(T,T,F))
odbcClose(myConn)
> class(X)
[1] "data.frame"
> class(X$ID)
[1] "character"
> class(X[,2])
[1] "character"
> class(X[,3])
[1] "integer"
I thought sqlQuery stored a query that was to be processed by
sqlGetResults. What's happening here?
Joe
More information about the R-help
mailing list