[R] importing excel-file

Alberto Monteiro albmont at centroin.com.br
Fri Apr 20 15:48:47 CEST 2007

Hans-Peter wrote:
>> I added colClasses = "double", and now it works - but I lose all
>> strings, that become NAs (they don't matter - maybe if they matter,
>> I just have to call read.xls twice). Without colClasses = "double",
>> the numbers become meaningless stuff.
> If a scalar colClasses argument is given, it will be recycled for all
> columns (see help). Thus a character value will be coerced to double
> and becomes NA.
> I don't understand though what is the matter with teh numbers 
> becoming meaningless stuff. 
I guess that's because Excel in Portuguese uses comma to separate
the integer to the fractional part.

> With:
> test9 <- read.xls( filename, sheet = "sheet name", rowNames = FALSE )
>  # (dateTimeAs argument default, i.e. "numeric")
> dateTimeToStr( test9$NumberColumn )
> you should get valid numbers (and dates). With
> dateTimeAs="isodatetime" there could be localization issues (i.e. the
> date time formatting of the cell is not recognized). But I'd need a
> test file to say for sure.
I sent you a file in private. But now I can't reproduce the error.
Somehow, the localization works fine with the test.xls file, but it
doesn't work with the important file.

OTOH, I guess I found a new problem. The attached file (in private,
R-help will filter it out) includes two spreadsheets. They are
exactly identical, as I tried to copy and paste them.

test1 <- read.xls(filename, sheet = 1, rowNames = FALSE) # works fine
test2 <- read.xls(filename, sheet = 2, rowNames = FALSE) # returns NULL

Alberto Monteiro

> -- 
> Regards,
> Hans-Peter
------- End of Original Message -------

More information about the R-help mailing list