Hi, Im getting the following error when I attempt to read a csv file into R. I have the file saved on my C drive. Id really appreciate it if anyone can help.... My Command:> survey <- read.csv (file = "C:\onlinesurvey.csv",head= TRUE, sep =",")Error: Error in file(file, "r") : unable to open connection In addition: Warning messages: 1: '\o' is an unrecognized escape in a character string 2: unrecognized escape removed from "C:\onlinesurvey.csv" 3: In file(file, "r") : cannot open file 'C:onlinesurvey.csv', reason 'No such file or directory' I have the file located on the C drive so I do not know why its telling me "no such file or directiry". -- View this message in context: http://www.nabble.com/Can-anyone-help---tp14888245p14888245.html Sent from the R help mailing list archive at Nabble.com.
The problem is that the backslash character (i.e., the "\" in "C:\online") is used to separate folder names on MS Windows, but it's used for something else in R. Try survey <- read.csv(file=file.path("C:", "onlinesurvey.csv"), head= TRUE, sep =",") -Ben p.s., As the posting guide instructs, please try to make your subject lines more descriptive than "help" or "error".> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] > On Behalf Of hoogeebear > Sent: Wednesday, January 16, 2008 1:35 PM > To: r-help at r-project.org > Subject: [R] Can anyone help?? > > > Hi, > > Im getting the following error when I attempt to read a csv file into R. I > have the file saved on my C drive. Id really appreciate it if anyone can > help.... > > My Command: > > > survey <- read.csv (file = "C:\onlinesurvey.csv",head= TRUE, sep =",") > > Error: > > Error in file(file, "r") : unable to open connection > > In addition: Warning messages: > 1: '\o' is an unrecognized escape in a character string > 2: unrecognized escape removed from "C:\onlinesurvey.csv" > 3: In file(file, "r") : > cannot open file 'C:onlinesurvey.csv', reason 'No such file or > directory' > > I have the file located on the C drive so I do not know why its telling me > "no such file or directiry". > -- > View this message in context: http://www.nabble.com/Can-anyone-help--- > tp14888245p14888245.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.The information transmitted in this electronic communication is intended only for the person or entity to whom it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this information in error, please contact the Compliance HelpLine at 800-856-1983 and properly dispose of this information.
FAQ Q 7.8 rw-FAQ Q 2.16 should both help, as perhaps should the warning about> unrecognized escape removed from "C:\onlinesurvey.csv"You need to use forward slashes or double the backslashes. On Wed, 16 Jan 2008, hoogeebear wrote:> > Hi, > > Im getting the following error when I attempt to read a csv file into R. I > have the file saved on my C drive. Id really appreciate it if anyone can > help.... > > My Command: > >> survey <- read.csv (file = "C:\onlinesurvey.csv",head= TRUE, sep =",")sep = "," is the default (the 'c' in csv stands for 'comma')> Error: > > Error in file(file, "r") : unable to open connection > > In addition: Warning messages: > 1: '\o' is an unrecognized escape in a character string > 2: unrecognized escape removed from "C:\onlinesurvey.csv" > 3: In file(file, "r") : > cannot open file 'C:onlinesurvey.csv', reason 'No such file or directory' > > I have the file located on the C drive so I do not know why its telling me > "no such file or directiry". >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Hi Guys, Thank you very much for the quick response. Adding the extra \ has fixed the errors. Thanks again, Regards, John. hoogeebear wrote:> > Hi, > > Im getting the following error when I attempt to read a csv file into R. I > have the file saved on my C drive. Id really appreciate it if anyone can > help.... > > My Command: > >> survey <- read.csv (file = "C:\onlinesurvey.csv",head= TRUE, sep =",") > > Error: > > Error in file(file, "r") : unable to open connection > > In addition: Warning messages: > 1: '\o' is an unrecognized escape in a character string > 2: unrecognized escape removed from "C:\onlinesurvey.csv" > 3: In file(file, "r") : > cannot open file 'C:onlinesurvey.csv', reason 'No such file or > directory' > > I have the file located on the C drive so I do not know why its telling me > "no such file or directiry". >-- View this message in context: http://www.nabble.com/Can-anyone-help---tp14888245p14888280.html Sent from the R help mailing list archive at Nabble.com.
Try replacing '\' with '/' Regards, -Cody Cody Hamilton Edwards Lifesciences -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of hoogeebear Sent: Wednesday, January 16, 2008 10:35 AM To: r-help at r-project.org Subject: [R] Can anyone help?? Hi, Im getting the following error when I attempt to read a csv file into R. I have the file saved on my C drive. Id really appreciate it if anyone can help.... My Command:> survey <- read.csv (file = "C:\onlinesurvey.csv",head= TRUE, sep =",")Error: Error in file(file, "r") : unable to open connection In addition: Warning messages: 1: '\o' is an unrecognized escape in a character string 2: unrecognized escape removed from "C:\onlinesurvey.csv" 3: In file(file, "r") : cannot open file 'C:onlinesurvey.csv', reason 'No such file or directory' I have the file located on the C drive so I do not know why its telling me "no such file or directiry". -- View this message in context: http://www.nabble.com/Can-anyone-help---tp14888245p14888245.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.