Skip to content

read.xls question

5 messages · Mathew, Abraham T, David Scott, Rodrigo Aluizio +2 more

#
I'm an R newbie and had a question about the read.xls function. I've heard that this is often not a reliable function to use for importing data. However, I have created numerous xls files which contain information about voter turnout and macroeconomic indicators in India. I'm writing a paper on the relationship between economic growth and voter turnout.
 
This is the command I use:
 
data <- read.xls("India.xls", header=TRUE)
 
I get the following error message:
Error: could not find function "read.xls"
 
 
Anyone have ideas?
Thanks,
Abraham
#
On Sat, 14 Mar 2009, Mathew, Abraham T wrote:

            
Since you are a beginner it is possible you missed a couple of steps. 
read.xls is part of the package xlsReadWrite so you need to first install 
that package, which is only possible if you are using Windows. Then you 
need to load the package with the command

library(xlsReadWrite)

Just checking on CRAN xlsReadWrite is not currently available. There is an 
archived version available however.

David Scott


_________________________________________________________________
David Scott	Department of Statistics
 		The University of Auckland, PB 92019
 		Auckland 1142,    NEW ZEALAND
Phone: +64 9 373 7599 ext 85055		Fax: +64 9 373 7018
Email:	d.scott at auckland.ac.nz

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics
#
To turn the function avaliable you have to load the library first, to  
do so:

library(xlsReadWrite)
Then you use your command read.xls.
I'm suposing that you already had installed the xlsReadWrite package.

A better alternative to this package is RODBC, which also read excel  
2007 files. Take a look on it at the CRAN web site.

Hope it helps.
Best wishes.

______________
Rodrigo Aluizio

Em 15/03/2009, ?s 00:27, "Mathew, Abraham T" <amathew at ku.edu> escreveu:
#
There are two read.xls functions: one is in gdata and one is in
xlsReadWrite packages and neither is unreliable.   You've simply
not loaded the package.  There is more info here and interfacing
to Excel:
http://wiki.r-project.org/rwiki/doku.php?id=tips:data-io:ms_windows

You should read the Introduction manual and see ?library for loading
a package.
On Sat, Mar 14, 2009 at 11:27 PM, Mathew, Abraham T <amathew at ku.edu> wrote:
1 day later
#
2009/3/15 David Scott <d.scott at auckland.ac.nz>:
Thanks for mentioning.

The reason is that CRAN is strict(er) now with binary submissions
(which is not a bad thing) and the build also broke technically with
R-2.9 because I used a private build variable which is no longer
supported. I adapted the package to use C code and download the
necessary 3rd party binary code from an external e.g. non-CRAN site.
Now I am waiting to get the ok from the 3rd party library provider
before submitting it again and see what is possible.

Besides from the archive you can get the xlsReadWrite package here:
http://treetron.googlepages.com/ (direct link:
http://treetron.googlepages.com/xlsReadWrite_1.3.3.zip). - As an R
newbie (OP) it is maybe better to use something more standard,e.g.
RODBC package, eventually (it's good but you need Perl!) the gdata
package or use plain old .csv files (but watch out fro dropped decimal
places!) .

2009/3/15 Rodrigo Aluizio <r.aluizio at gmail.com>:
If you mean better because of Excel 2007 then I disagree: xls files
work well with Excel 2007, the format is widely in use and if you
reach their limit (65536 rows by 256 columns) you'd better choose a
database (and use RODBC) imho. Reading natively without depending on
additional layers (driver, perl, COM) benefits too. - If you mean
'more R standard' or OSS then I agree.

Cheers,
Hans-Peter