Hello! I have just uninstalled the R 2.4.1 that i was using and installed the latest version (R 2.12.1). In order to read a text file, i was copying the text file to C/Program Files/R/R 2.4.1, and the previous version was able to read it from there. I did the same think for the new version (copy text file to C/Program Files/R/R 2.12.1) and i tried to open it: data <- read.table('intersand.txt') but the result was: Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'intersand.txt': No such file or directory Can someone tell me what the problem is? Must i copy the text file somewhere else? Thank you in advance, George Pantopoulos [[alternative HTML version deleted]]
Hello, Make sure you have your file in your workspace directory (you can get it on your R console with the command getwd()). HTH, Samuel -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of George Pantop Sent: 08 February 2011 13:19 To: r-help at r-project.org Subject: [R] text file problem-Help needed Hello! I have just uninstalled the R 2.4.1 that i was using and installed the latest version (R 2.12.1). In order to read a text file, i was copying the text file to C/Program Files/R/R 2.4.1, and the previous version was able to read it from there. I did the same think for the new version (copy text file to C/Program Files/R/R 2.12.1) and i tried to open it: data <- read.table('intersand.txt') but the result was: Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'intersand.txt': No such file or directory Can someone tell me what the problem is? Must i copy the text file somewhere else? Thank you in advance, George Pantopoulos [[alternative HTML version deleted]] __________ Information from ESET NOD32 Antivirus, version of virus signature database 5855 (20110208) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __________ Information from ESET NOD32 Antivirus, version of virus signature database 5855 (20110208) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com
On 08/02/2011 8:19 AM, George Pantop wrote:> Hello! > I have just uninstalled the R 2.4.1 that i was using and installed the latest version (R 2.12.1). > In order to read a text file, i was copying the text file to C/Program Files/R/R 2.4.1, and the previous version was able to read it from there. > > I did the same think for the new version (copy text file to C/Program Files/R/R 2.12.1) and i tried to open it: > > data<- read.table('intersand.txt') > > but the result was: > > Error in file(file, "rt") : cannot open the connection > In addition: Warning message: > In file(file, "rt") : > cannot open file 'intersand.txt': No such file or directory > > Can someone tell me what the problem is? Must i copy the text file somewhere else?Use setwd(choose.dir()) to set the current working directory wherever your file is, then you'll be able to read it. Or use read.table(file.choose()) to find the file and read it from wherever it was sitting. Duncan Murdoch
The windows installer normally makes .RData files double-clickable, and when you start R that way it sets your working directory to the directory containing the .RData file. I recommend that you use this feature to set your working directory to a location convenient for you. You can also set the directory from the File menu, but for everyday uses the following procedure is more convenient. Start by using the Start menu to start R. Immediately select File-Save Workspace, and use the dialog to select the directory where your text file is and give the new .RData file a name. Save the file and quit. Now find the RData file and double-click it. This should open RGui and your current directory for that RGui session. You should be able to read and write text or other files in that working directory readily for the rest of that working session. This allows you to easily keep all of your data organized in directories by the project you are working on. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. George Pantop <george_pantop@yahoo.gr> wrote: Hello! I have just uninstalled the R 2.4.1 that i was using and installed the latest version (R 2.12.1). In order to read a text file, i was copying the text file to C/Program Files/R/R 2.4.1, and the previous version was able to read it from there. I did the same think for the new version (copy text file to C/Program Files/R/R 2.12.1) and i tried to open it: data <- read.table('intersand.txt') but the result was: Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : � cannot open file 'intersand.txt': No such file or directory Can someone tell me what the problem is? Must i copy the text file somewhere else? Thank you in advance, George Pantopoulos [[alternative HTML version deleted]]_____________________________________________ R-help@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. [[alternative HTML version deleted]]