[R] Setting the working directory on Windows (was: Replacing backslashes with slashes)

Berton Gunter gunter.berton at gene.com
Thu Jan 5 20:11:40 CET 2006


In a similar vein, a GUI version is:

setwd(dirname(choose.files()))

This gives you a standard Windows file browser -- you just click on any file
in the directory you want to set. Obviously, dirname(choose.files()) is an
easy interactive way to get directories as strings if you need them. See
also ?basename . 


-- 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 Duncan Golicher
> Sent: Thursday, January 05, 2006 10:11 AM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] Replacing backslashes with slashes
> 
> It  is often convenient to quickly set the working directory 
> to a path 
> copied onto the windows clipboard. A simple trick I have been 
> using for 
> a while is along the lines given in the previous posts.
> 
> setwd.clip<-function()
> {
>   options(warn=-1)
>   setwd(gsub("\\\\","/",readLines("clipboard")))
>   options(warn=0)
>   getwd()
> }
> 
> 
> I load this at the start of every session and then write setwd.clip() 
> whenever I have a path I want to change to on the clipboard. 
> You can of 
> course write
> 
> setwd(gsub("\\\\","/",readLines("clipboard")))
> 
> everytime you need it. Obviously it takes longer and there is 
> the minor 
> detail that the path read from the clipboard is incomplete (no EOL 
> marker) which leads to an unnecessary warning.
> 
> 
> Dr Duncan Golicher
> Ecologia y Sistematica Terrestre
> Conservación de la Biodiversidad
> El Colegio de la Frontera Sur
> San Cristobal de Las Casas, 
> Chiapas, Mexico
> 
> Email: dgoliche at sclc.ecosur.mx 
> 
> Tel: 967 674 9000 ext 1310
> Fax: 967 678 2322
> Celular: 044 9671041021
> 
> United Kingdom Skypein; 020 7870 6251
> Skype name: duncangolicher 
> Download Skype from http://www.skype.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
>




More information about the R-help mailing list