[R] import csv file problem

Erik Iverson eriki at ccbr.umn.edu
Thu Sep 23 02:38:27 CEST 2010


On 09/22/2010 07:24 PM, sisxy wrote:
>
> Hello, i am trying to import the csv file into R .
> i have a file saved as csv in my desktop.
> My laptop is Window vista, version R is 2.10.1.
>
> then i used the code
>> Q<-read.csv("Q.csv",header=TRUE)

R will search in its working directory for Q.csv.

What is the working directory, use getwd() to
find out.

>
> then my error is
>
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") :
>    cannot open file 'Q.csv': No such file or directory
>
> i already search the previous solution....
> i am confused , because
> some say for the file name is C:\\Q.csv
> so i change to
>
>> xx<-read.csv("C:\\desktop\\xx.csv",header=TRUE)
>
> but ,
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") :
>    cannot open file 'C:\desktop\xx.csv': No such file or directory
>>
>
>
> any problem for my code ? any problem for the location of the file i saved
> or other possible problem that i dont know ?

Well, you need to know the path to your Windows desktop,
which has nothing do to with R.  If I recall correctly from
when I used Windows, it might be something like..

C:/Documents and Settings/Username/Desktop ?

Or something like that?  I don't know if you need
to escape spaces.

You might also have luck using file.choose() as the first
argument to read.csv.



More information about the R-help mailing list