####################################################################### # clean a path and unlist it (for setDir()) # - expects Windows backslashes '\' cleanPath <- function(filename = choose.files()){ x <- gsub('\\\\','/', filename) # nice easy way to find and clean the path y <- (gregexpr('/', x)) # vector of positions of / return(list(path=x, pos=y)) } ####################################################################### # takes CleanPath() output as arg, returns just the filename justFile <- function(x) { pos <- unlist(x$pos) pos <- pos[length(pos)] fname <- substring(x$path, pos+1, nchar(x$path)) return(fname) } ####################################################################### # nukem - erase all objects (after asking nicely) nukem <- function(){ x <- readline ("\n\tErase all objects? (Y)") if (tolower(substr(x, 1, 1)) != "n") {rm(list=ls(all=TRUE))}# NUKE all objects else {print("Nothing was changed.")} }