[R] RODBC: Trying to read an Excel file
Duncan Murdoch
murdoch at stats.uwo.ca
Thu Jun 25 16:28:08 CEST 2009
On 6/25/2009 7:20 AM, John Sorkin wrote:
> R 2.8
> Windows XP
> Excel 2003
>
> I am trying to read an Excel spread sheet. I have looked at the RODBC help pages and am having trouble setting up code that will work. My code and the results are pasted below:
>
>
>> jo<-odbcConnectExcel("i:\\all\\sorkinjohn\\stats\\silvermannatalie\\NEMOcombined06-24-09.xls",readOnly = TRUE)
>> mo<-sqlGetResults(jo)
You set up a connection, but didn't submit a query, so there are no
results to get.
You need to do something like sqlQuery("select * from tablename"), where
tablename is a "table" within your spreadsheet. The ?odbcConnectExcel
page links to
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q195951 which
describes how to specify one.
Duncan Murdoch
>> mo
> [1] -1
>
> I have tried to set up the connection string using odbcConnectExcel and then have tried to read the file using sqlGetResults. Can someone tell me what I am doing wrong?
>
> Thanks,
> John
>
> John David Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>
> Confidentiality Statement:
> This email message, including any attachments, is for th...{{dropped:6}}
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list