[R] importing excel-file

Hans-Peter gchappi at gmail.com
Fri Apr 20 14:49:56 CEST 2007


> This is Windows XP, Excel 2003, R 2.4.1.
> Maybe the problem is with Windows XP. I know that it locks some
> files, even when I open for reading. For example, if I open 'test.xls'
> file, then I can't issue the DOS command 'copy test.xls new_test.xls'.

Thanks for your information. Will test sometimes later.


> 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. 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.


-- 
Regards,
Hans-Peter



More information about the R-help mailing list