Hi User's, This might be a simple question but it is giving me a hard time as I am a new user. I installed R version 2.9.2 (2009-08-24) 1. I just copied a short script from Fox (2002) as a practice and wanted to save it as Rossi.R. The system saved it without complain but when I looked at using a windows explorer it is not *.R file but only Rossi. Why this is happening? 2. the script and the data files are in the same working directory. When I run the following script > Rossi <- read.table('Rossi',header=T) > Rossi[1:5,1:10] I got the following error messages Error in file(file, "r") : cannot open the connection In addition: Warning message: In file(file, "r") : cannot open file 'Rossi': No such file or directory > Rossi[1:5,1:10] Error: object 'Rossi' not found Thank you for your help in advance Val [[alternative HTML version deleted]]
Hi Val, I am not sure what it is that you are trying to do. "read.table" Is not used to open an R script, but to open a data file. You will also need to give the extension of the file when using the command (someone please correct me if I am wrong). If you wish to open an R script, I would just use the GUI menu and use: "file -> open script" and find your script to open. Good luck, Tal ---------------------------------------------- My contact information: Tal Galili E-mail: Tal.Galili@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Wed, Oct 28, 2009 at 4:04 PM, Val <valkremk@gmail.com> wrote:> Hi User's, > > This might be a simple question but it is giving me a hard time as I am a > new user. > I installed R version 2.9.2 (2009-08-24) > > 1. I just copied a short script from Fox (2002) as a practice and wanted > to save it as Rossi.R. > The system saved it without complain but when I looked at using a windows > explorer it is not *.R file but only Rossi. Why this is happening? > > 2. the script and the data files are in the same working directory. When I > run the following script > > > Rossi <- read.table('Rossi',header=T) > > Rossi[1:5,1:10] > > I got the following error messages > > Error in file(file, "r") : cannot open the connection > In addition: Warning message: > In file(file, "r") : cannot open file 'Rossi': No such file or > directory > > Rossi[1:5,1:10] > Error: object 'Rossi' not found > > > Thank you for your help in advance > > Val > > [[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]]
Hi Val, Windows does not display extensions by default. Check the 'Type' column; it should read 'R file'. Keep in mind what you are dealing with; Rossi.R is a script, so you cannot open it with read.table. You have to use source() for that. Moreover, use the extension, as well (Rossi.R, not Rossi) Cheers! On Wed, Oct 28, 2009 at 3:04 PM, Val <valkremk at gmail.com> wrote:> Hi User's, > > This might be a simple question but it is giving me a hard time as I am a > new user. > I installed ?R version 2.9.2 (2009-08-24) > > 1. I just copied a short script from Fox (2002) as a practice ? and wanted > to save it as Rossi.R. > The system saved it without complain but when I looked at ?using a windows > explorer ?it is not *.R file but only Rossi. Why this is happening? > > 2. the script and the data files are in the same working directory. When I > run the following script > > ? ?> ?Rossi <- read.table('Rossi',header=T) > ? > ? Rossi[1:5,1:10] > > I got the following error messages > > ? ? ? ? ? ?Error in file(file, "r") : cannot open the connection > ? ? ? ? ? ?In addition: Warning message: > ? ? ? ? ? ?In file(file, "r") : cannot open file 'Rossi': No such file or > directory > ? ? ? ? ?> Rossi[1:5,1:10] > ? ? ? ? ? Error: object 'Rossi' not found > > > Thank you for your help in advance > > Val > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > 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. >
On Oct 28, 2009, at 10:04 AM, Val wrote:> Hi User's, > > This might be a simple question but it is giving me a hard time as I > am a > new user. > I installed R version 2.9.2 (2009-08-24) > > 1. I just copied a short script from Fox (2002) as a practice and > wanted > to save it as Rossi.R.How?> The system saved it without complain but when I looked at using a > windows > explorer it is not *.R file but only Rossi. Why this is happening?If you were to include the code, we perhaps could tell you. In its default mode Windows may be hiding the extension from you. (Or possibly because R does not postpend file types and (I am now guessing here about a package I have not used and don't even know if you are) neither does Rcmdr.)> > 2. the script and the data files are in the same working directory. > When I > run the following script > >> Rossi <- read.table('Rossi',header=T)No path specification. And ??? thought you said it was a script, which would have been loaded with source()>> Rossi[1:5,1:10]But this suggests you are using it as data. ???? What do you get when your type this: getwd() Maybe if you tried (untested)... Nah ... not going to do further guessing. Read the posting guide and supply the missing elements.> > I got the following error messages > > Error in file(file, "r") : cannot open the connection > In addition: Warning message: > In file(file, "r") : cannot open file 'Rossi': No such > file or > directory >> Rossi[1:5,1:10] > Error: object 'Rossi' not found > > > Thank you for your help in advance > > Val-- David Winsemius, MD Heritage Laboratories West Hartford, CT