[R] for importing "data"

Hans-Peter gchappi at gmail.com
Mon Oct 30 11:04:25 CET 2006


Hi,

> *I had an Excel file,  then I turned it into a "tab-delimited" file, as
> ...
> lahore<-read.delim("lahore.txt")

I suppose you are on windows, hence you can use the package
xlsReadWrite to read the Excelfile directly. It's on the CRAN and you
can download it from the RGui under the menu: Packages ->  Install
package(s)... (select a mirror, download).

Example: lahore <- read.xls( "lahore.xls" )

Gives back the data from the first sheet as a data.frame and assumes
that there is a header row. Without header row set the colNames
argument to FALSE.

This is a user contributed package and doesn't belong to the core R
environment, hence you shouldn't post in this group if need help with
it (contact me or much better go to:
http://groups.google.ch/group/supportR). xlsReadWrite is a bit
non-standard and currently non-portable. So maybe not appropriate for
a novice. On the other hand it is easy to use and no need for csv
detours to get your data...

> Error in file(file, "r") : unable to open connection
> In addition: Warning message:
> cannot open file 'lahore.txt', reason 'No such file or directory'

Already answered: ?getwd  ?setwd

-- 
Regards,
Hans-Peter



More information about the R-help mailing list