Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

Folders and Files



> getwd()
> setwd("h:/work/")
> file.exists("filename")	# Returns a boolean
> unlink("filename")            # Deletes the file or directory
> fname <- file.choose()        # An interactive, completing, file chooser.
> choose.dir()
> dir <- tclvalue(tkchooseDirectory()) # GUI which requires library(tcltk).

A useful utility on a MS/Windows environment, where backslashes are used in paths, and R likes to have forward slashes, is the following (Duncan Golicher, 5 Jan 2006, r-help):

setwd.clip <- function()
{
  options(warn=-1)
  setwd(gsub("\\\\", "/",readLines("clipboard")))
  options(warn=0)
  getwd()
}

Then, simply select a path into your clipboard (Ctrl-C), then in R call setwd.clip!



Copyright © 2004-2005
Brought to you by Togaware.