[R] trouble with reading data from excel

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Sep 12 21:14:36 CEST 2005


"sloan jones" <sledepi at operamail.com> writes:

> I have been trying to open data that I have saved in an excel spread sheet.  I saved it as a csv.  Then I tried using the read.csv command. However, everytime I do this--
> 
> diseasedat<-read.csv("M:/sloan/R/disease/disease.csv", sep=,  header = TRUE, fill= TRUE)--
> 
> I get an error message:  
> 
> Error in file(file, "r") : unable to open connection
> In addition: Warning message:
> cannot open file 'M:/sloan/R/disease/disease.csv'
> 
> What am I doing wrong or what should I look for to correct this?

First (must be said) check that you got the filename right...

If the name is right: Did you close Excel before trying to read the
file? Sometimes Windows applications hang onto their files and prevent
others from opening them. Can you open it in other applications?

The read.csv call looks a little odd -- you shouldn't need extra
arguments, just read.csv or read.csv2 depending on locale. However,
that shouldn't cause that sort of error message.

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907




More information about the R-help mailing list