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)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 ? Really need urgent help ... thanks -- View this message in context: http://r.789695.n4.nabble.com/import-csv-file-problem-tp2551256p2551256.html Sent from the R help mailing list archive at Nabble.com.
You are not in the correct directory. Use read.csv(file.choose()) so that you can interactively choose the correct location. On Wed, Sep 22, 2010 at 8:24 PM, sisxy <xueyingkoo at gmail.com> 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) > > 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 ? > > Really need urgent help ... > thanks > > -- > View this message in context: http://r.789695.n4.nabble.com/import-csv-file-problem-tp2551256p2551256.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
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.
> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of sisxy > Sent: Wednesday, September 22, 2010 5:25 PM > To: r-help at r-project.org > Subject: [R] import csv file problem > > > 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) > > 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 ? > > Really need urgent help ... > thanks >I presume you are working in some version of Windows OS. You have used several different paths to the file in your description above. What is the exact location of the file in Windows? Is it C:\q.csv C:\desktop\q.csv C:\desktop\xx.csv Or something else. Unless we know the exact name of the file and the directory in which it is located, there is not much we can do to help. Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204