Re: [R] Replacing backslashes with slashes

From: Duncan Golicher <dgoliche_at_sclc.ecosur.mx>
Date: Fri 06 Jan 2006 - 05:11:27 EST


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@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@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 Received on Fri Jan 06 05:17:11 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:51 EST