R is quite a powerful environment. Here's a small way it could be even better. I wanted to change the working directory, so I tried the obvious thing> cd("foo")Error: couldn't find function "cd" Then I looked for `directory' in the FAQ but found nothing. A search for directory in the introduction also turned up nothing. A Google search for "gnu R change directory" brought up a link to the Windows FAQ, and there was the answer: setwd. Oddly enough, setwd is not mentioned in the general FAQ, the introduction, or the language definition. Hopefully someone can add a mention of setwd to the general FAQ or the intro. Even better would be to have a cd() command, since that's what almost every beginner will try first.
You do not say, but if you are on Windows see the R for Windows FAQ 2.14 where getwd() is explicitly mentioned. setwd() is on the same man page. Also the R for Windows File menu has a "Change dir ..." entry. So I think R core has already taken care of this, at least on Windows. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Issac Trotts > Sent: Tuesday, May 09, 2006 2:51 PM > To: r-help at stat.math.ethz.ch > Subject: [R] Can't there be a cd command? > > R is quite a powerful environment. Here's a small way it > could be even better. > > I wanted to change the working directory, so I tried the obvious thing > > > cd("foo") > Error: couldn't find function "cd" > > Then I looked for `directory' in the FAQ but found nothing. A search > for directory in the introduction also turned up nothing. > > A Google search for "gnu R change directory" brought up a link to the > Windows FAQ, and there was the answer: setwd. Oddly enough, setwd is > not mentioned in the general FAQ, the introduction, or the language > definition. > > Hopefully someone can add a mention of setwd to the general FAQ or the > intro. Even better would be to have a cd() command, since that's what > almost every beginner will try first. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
From: Paul Johnson> > It is a FAQ in our Linux lab. People start emacs and fire up > R via ess, and then they have no idea 'where they are". For > computer experts, it is not a problem, but for people who > don't know much about computers, it is a pretty big problem. > They have data in some subdirectory, but almost invariably > they don't get emacs & R started from that same place.ESS by default will prompt for start-up directory when starting R. Perhaps that was turned off in the lab?> Unfortunately, for our users, it does not help to simply > re-label setwd as cd. Both commands imply a deeper > understanding of the OS than they have. Also, unfortunately, > these are the same people who don't understand that FAQs > exist and should be consulted. These people are so new/timid > that asking in r-help would be the last thing to cross their mind. > > I've wondered if it would not help to have the R prompt > include the directory name, as in an x terminal.Here's one possibility (on WinXP Pro):> h <- taskCallbackManager() > h$add(function(expr, value, ok, visible) {+ options(prompt=paste(getwd(),"> ", sep="")) + return(TRUE)}, name="pwdprompt") [1] "pwdprompt" C:/home > setwd("projects") C:/home/projects > Andy> pj > > On 5/10/06, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote: > > > > > Exactly. I don't think I have ever used setwd() on Linux. > > > > Also, I have never seen this asked before for a Unix-alike, so it > > seems not to be a >F<AQ. There is a common tendency for > users who run > > into a problem to think everyone does too, and it isn't > necessarily so. > > Frequently asked questions do make it to the FAQs: it is a defence > > mechanism for the volunteers supporting R. > > > > help.search("directory") gets you there. > > > > -- > > 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 > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > > -- > Paul E. Johnson > Professor, Political Science > 1541 Lilac Lane, Room 504 > University of Kansas > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >
When talking about user friendlyness of computer software I like the analogy of cars vs. busses: Busses are very easy to use, you just need to know which bus to get on, where to get on, and where to get off (and you need to pay your fare). Cars on the other hand require much more work, you need to have some type of map or directions (even if the map is in your head), you need to put gas in every now and then, you need to know the rules of the road (have some type of drivers licence). The big advantage of the car is that it can take you a bunch of places that the bus does not go and it is quicker for some trips that would require transfering between busses. Using this analogy programs like SPSS are busses, easy to use for the standard things, but very frustrating if you want to do something that is not already preprogrammed. R is a 4-wheel drive SUV (though environmentally friendly) with a bike on the back, a kayak on top, good walking and running shoes in the pasenger seat, and mountain climbing and spelunking gear in the back. R can take you anywhere you want to go if you take time to leard how to use the equipment, but that is going to take longer than learning where the bus stops are in SPSS. Now there are tools like Rcmdr that help get you started (maybe a gps unit in the R suv above), but if we make R too user friendly then we limit what can be done with it. I think the volume of mail in R-help is partly due to lack of friendliness, but a lot of it is due to the flexibility as well, if it did less, there would be less to learn and ask questions about. I for one prefer to do a little more work learning the program in exchange for being able to do a lot more with it. To mangle a famous Einstien quote: "Statistical packages should be made as user friendly as possible, but no friendlier." -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111 -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Manuel L?pez-Ib??ez Sent: Wednesday, May 10, 2006 2:19 PM To: r-help at stat.math.ethz.ch Subject: Re: [R] Can't there be a cd command? Jan T. Kim wrote:> > That's an idea I like very much too -- much better than the currently > popular idea of "protecting" users from the "unfriendliness" of > programming, anyway... >It is just my opinion that the amount of mail in R-help speaks volumes about the current "friendliness" [1], or lack thereof, of R. Perhaps I am just the only one who thinks this way... [1] http://en.wikipedia.org/wiki/Usability ______________________________________________ LLama Gratis a cualquier PC del Mundo. Llamadas a fijos y m?viles desde 1 c?ntimo por minuto. http://es.voice.yahoo.com ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Duncan Murdoch wrote (amongst other things):> Statistical computing is not easy, so how could R be? Who has ever > claimed it is? Any package that makes statistical computing appear to > be easy is probably giving you wrong answers half the time, or is > extremely limited in scope.Well expressed, Duncan! (A slam Dunc, one might say. :-) ) cheers, Rolf
Reasonably Related Threads
- assignInNamespace to create a setwd() replacement: how to use unlockBinding()?
- locked binding of setwd() in R 2.15.x causes .Rprofile to fail
- .Rprofile replacement function setwd() causing errors
- setwd in windows
- Sweave: conflict between setwd and \SweaveOpts{prefix.string=}