Hi everyone, this is my first time using r and I think I'm overlooking something small and I just need some help seeing it. I have a file in notepad that I need to read into r.> ceosalary<-read.table(file="C:/Users/mz106_010/Desktop/ceosalary.csv",header > = TRUE,sep="\t")Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'C:/Users/mz106_010/Desktop/ceosalary.csv': No such file or directory> ceosalary<-read.table(file="C:/Users/mz106_010/Desktop/ceosalary.txt",header > = TRUE,sep="\t")Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'C:/Users/mz106_010/Desktop/ceosalary.txt': No such file or directory am I writing one of those incorrectly? What can I do to fix the problem? Any help would be greatly appreciated. Thanks for your time everyone! -- View this message in context: http://r.789695.n4.nabble.com/r-noobie-reading-my-text-file-into-r-tp4684871.html Sent from the R help mailing list archive at Nabble.com.
When starting out I sometimes find it easier to do the following: Ceosalary<-read.table(file.choose(),sep="\t") This will give you a dialog box to find the file you want and you won't have to worry about getting the full path exactly right. Hth, Mike W. Michael Conklin Executive Vice President | Marketing Science GfK Custom Research, LLC | 8401 Golden Valley Road | Minneapolis, MN, 55427 T +1 763 417 4545 | M +1 612 567 8287 www.gfk.com -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of frankreynolds Sent: Thursday, February 06, 2014 12:01 PM To: r-help at r-project.org Subject: [R] r noobie, reading my text file into r Hi everyone, this is my first time using r and I think I'm overlooking something small and I just need some help seeing it. I have a file in notepad that I need to read into r.> ceosalary<-read.table(file="C:/Users/mz106_010/Desktop/ceosalary.csv", > header > = TRUE,sep="\t")Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'C:/Users/mz106_010/Desktop/ceosalary.csv': No such file or directory> ceosalary<-read.table(file="C:/Users/mz106_010/Desktop/ceosalary.txt", > header > = TRUE,sep="\t")Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'C:/Users/mz106_010/Desktop/ceosalary.txt': No such file or directory am I writing one of those incorrectly? What can I do to fix the problem? Any help would be greatly appreciated. Thanks for your time everyone! -- View this message in context: http://r.789695.n4.nabble.com/r-noobie-reading-my-text-file-into-r-tp4684871.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.
I would guess the problem is that the file is not where you think it is or that you spelled the file name and/or path incorrectly. An easy thing to try is: read.table(file=file.choose(), header=TRUE, sep="\t") The function file.choose() will open a window where you'll have to choose the file from directories. This way, you're sure to select a file that exists and to input the correct path. HTH, Ivan -- Ivan CALANDRA Universit? de Franche-Comt? UFR STGI - UMR 6249 Chrono-Environnement 4 Place Tharradin - BP 71427 25211 Montb?liard Cedex, FRANCE +33 (0) 3 81 99 46 72 (rarely in the office) ivan.calandra at univ-fcomte.fr http://biogeosciences.u-bourgogne.fr/calandra Le 06/02/14 19:00, frankreynolds a ?crit :> Hi everyone, this is my first time using r and I think I'm overlooking > something small and I just need some help seeing it. I have a file in > notepad that I need to read into r. >> ceosalary<-read.table(file="C:/Users/mz106_010/Desktop/ceosalary.csv",header >> = TRUE,sep="\t") > Error in file(file, "rt") : cannot open the connection > In addition: Warning message: > In file(file, "rt") : > cannot open file 'C:/Users/mz106_010/Desktop/ceosalary.csv': No such file > or directory >> ceosalary<-read.table(file="C:/Users/mz106_010/Desktop/ceosalary.txt",header >> = TRUE,sep="\t") > Error in file(file, "rt") : cannot open the connection > In addition: Warning message: > In file(file, "rt") : > cannot open file 'C:/Users/mz106_010/Desktop/ceosalary.txt': No such file > or directory > > am I writing one of those incorrectly? What can I do to fix the problem? Any > help would be greatly appreciated. Thanks for your time everyone! > > > > -- > View this message in context: http://r.789695.n4.nabble.com/r-noobie-reading-my-text-file-into-r-tp4684871.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. >