blob: f62b1ce5e7a68663a1506a2d33c452ed99bfa7d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
######################################################################## 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 filenamejustFile <- 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.")}}
|