[R] Can't there be a cd command?

Duncan Murdoch murdoch at stats.uwo.ca
Wed May 10 16:30:35 CEST 2006


On 5/10/2006 10:11 AM, Liaw, Andy wrote:
> 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 > 

That doesn't quite work in the current Rgui, because the menu function 
to change directories (File | Change dir...) doesn't trigger the 
callback.  Not sure if that's a bug or not...

Duncan Murdoch




More information about the R-help mailing list