[R] Question regarding S4 objects and reading in excel data with RODBC

Sander sander1981 at gmail.com
Wed Aug 4 11:38:20 CEST 2010


L.S.

I am trying to get data from an excel sheet using the RODBC library, quite
like the example on page 34 of the 'Data manipulation with R' book written
by Phil Spector. It seems very straightforward, yet I get the same error
everytime I try it, with different excel sheets and trying to tweek the code
a bit. This is what I do:

library(RODBC)

sheet='X:\\example.xls'
con=odbcConnectExcel(sheet)

tbls=sqlTables(con)
tbls$TABLE_NAME
qry=paste("SELECT * FROM '",tbls at TABLE_NAME[1],"'", sep=" ")


The error I get is:
Error in paste("SELECT * FROM '", tbls at TABLE_NAME[1], "'", sep = " ") : 
  trying to get slot "TABLE_NAME" from an object (class "data.frame") that
is not an S4 object

Does anyone know what I'm doing wrong here? I have to admit that I don't
know much about sql.


Best regards,

Sander van Kuijk
-- 
View this message in context: http://r.789695.n4.nabble.com/Question-regarding-S4-objects-and-reading-in-excel-data-with-RODBC-tp2313170p2313170.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list