[R] Excel *.xls files, RODBC

Chuck Cleland ccleland at optonline.net
Sat Dec 4 16:10:01 CET 2004

   The following works for me under WinXP Pro to create "myframe" as a 
data frame:

z <- odbcConnectExcel("c:/myfolder/mydata.xls")
myframe <- sqlFetch(z, "Sheet1")

   Are you indicating the name of the worksheet you want within the 
*.xls file?  I suspect there could be additional issues on a non-Windows 
OS that I don't know about.

hope this helps,

Chuck Cleland

Rolf Turner wrote:
> I gather from reading the back-issues of r-help that it should be
> possible (modulo a number of caveats) to read an excel (yuck!) file
> into R using RODBC.  I have obtained and installed ODBC and the RODBC
> package, but cannot for the life of me figure out how to go about
> it.  Can anyone give me a simple recipe?
> I have an excel file on cdrom, say:
> 	/mnt/cdrom/melvin.xls
> I have started R and loaded the RODBC package.  I want to create
> a data frame ``melvin'' by reading in /mnt/cdrom/melvin.xls.
> What (in monosyllables --- step by step) do I do next?

Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894

More information about the R-help mailing list