Hello, Please forgive me that this question is so basic, but i have not been able to find a solution in any of the basic R introductions, in the R wiki, or in the stats textbook i'm using to learn R. I run R on a macintosh, and i have not been able to load any data files yet. For instance, if I have a data table in a file called schools.txt on my desktop, i've been trying to load the table as such:> schools <- > read.table("c:\harddrivename\users\username\desktop\schools.txt", > header=T,row.names=1)(obviously for the purposes of posting in this forum i've entered generic folder names.) No matter how i ammend the path, i get the following error message: Error in file(file, "r") : cannot open the connection In addition: Warning message: In file(file, "r") : cannot open file 'c:\harddrivename\users\username\desktop\schools.txt': No such file or directory. I'm guessing that there's a different way to enter the path name on a macintosh? Thanks for your help! -- View this message in context: http://www.nabble.com/loading-a-file-in-R-in-mac-OS-X-tp24514721p24514721.html Sent from the R help mailing list archive at Nabble.com.
On Thu, Jul 16, 2009 at 1:32 PM, caballo<jamespitts at hotmail.com> wrote:> Error in file(file, "r") : cannot open the connection > In addition: Warning message: > In file(file, "r") : > cannot open file 'c:\harddrivename\users\username\desktop\schools.txt': > No such file or directory. > > I'm guessing that there's a different way to enter the path name on a > macintosh?There is no such thing as a c-drive on a Mac. Try this location instead: ~/Desktop/schools.txt and note that Mac is case-sensitive. The tilde (~) refers to your home directory. Alternatively you could write: /Users/username/Desktop/schools.txt -- Michael Knudsen micknudsen at gmail.com http://lifeofknudsen.blogspot.com/
On Jul 16, 2009, at 6:32 AM, caballo wrote:> > Hello, > > Please forgive me that this question is so basic, but i have not > been able > to find a solution in any of the basic R introductions, in the R > wiki, or in > the stats textbook i'm using to learn R. I run R on a macintosh, and > i have > not been able to load any data files yet. For instance, if I have a > data > table in a file called schools.txt on my desktop, i've been trying > to load > the table as such: > >> schools <- >> read.table("c:\harddrivename\users\username\desktop\schools.txt", >> header=T,row.names=1) > > (obviously for the purposes of posting in this forum i've entered > generic > folder names.) > > No matter how i ammend the path, i get the following error message: > > Error in file(file, "r") : cannot open the connection > In addition: Warning message: > In file(file, "r") : > cannot open file 'c:\harddrivename\users\username\desktop > \schools.txt': > No such file or directory. > > I'm guessing that there's a different way to enter the path name on a > macintosh? > > Thanks for your help!You are using a Windows based file path and on Windows, you would need to double the backslashes. See: http://cran.r-project.org/bin/windows/base/rw-FAQ.html#R-can_0027t-find-my-file On OSX, there is no "C:" drive and you would use forward slashes. The typical file path on OSX would be: /Users/username/Desktop/schools.txt If you are using the OSX GUI (R.app) you may also want to review the OSX FAQ: http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#R_002eapp There is a Mac/OSX specific R e-mail list, which you should consider subscribing to. More info: https://stat.ethz.ch/mailman/listinfo/r-sig-mac As it sounds like you are new to Macs and will be spending more time on them, you might also consider picking up a good Intro to OSX book, of which there are many. Check your local bookstore or Amazon. Pogue's books have generally worked well for folks: http://www.amazon.com/Mac-OS-Leopard-Missing-Manual/dp/059652952X http://www.amazon.com/Switching-Mac-Missing-Manual-Leopard/dp/0596514123/ HTH, Marc Schwartz
On Thu, Jul 16, 2009 at 2:44 PM, Marc Schwartz<marc_schwartz at me.com> wrote:> If you are using the OSX GUI (R.app) you may also want to review the OSX > FAQ:If you use the GUI, you may also just want to hit cmd+d and browse to your preferred working directory. If you set the working directory to Desktop, you can just type read.table("school.txt",...) I would, however, suggest that you move your files to a directory specifically dedicated to your R project in order not to clutter up your desktop. -- Michael Knudsen micknudsen at gmail.com http://lifeofknudsen.blogspot.com/
On Jul 16, 2009, at 8:15 AM, Michael Knudsen wrote:> On Thu, Jul 16, 2009 at 3:04 PM, Marc Schwartz<marc_schwartz at me.com> > wrote: > >> Actually, by default, the OSX HFS+ file system is not case sensitive: > > Sorry. I just took that for granted, as Mac (at least in a terminal) > is very similar to Linux.Not a problem. Coming to OSX after 8 years on Linux myself, it took a bit to get used to. As OSX is BSD Unix derived, there are similarities with Linux, but Apple has not surprisingly done some things that deviate from otherwise expected behavior. The HFS+ file system is one area, when compared to ext3 or now ext4 on Linux. A good book (and quick read) that I picked up which helped with the transition is: Mac for Linux Geeks Tony Steidler-Dennison Apress, 2009 http://www.amazon.com/Linux-Geeks-Experts-Voice-Source/dp/1430216506 HTH, Marc