Skip to content
Prev 200241 / 398503 Next

Change working directory

anna_l wrote:

            
Hi Anna,
I create a .First function that is run when the session starts that looks like this:

.First<-function () {
  options(editor="nedit",show.signif.stars=FALSE)
  source("SelectAnalysis.R")
}

This runs the file "SelectAnalysis.R" that looks like this:

cat("(B)ullying\n(P)alatability\nR\n")
answer<-toupper(readline("Enter the letter corresponding to the project - "))
if(answer == "B") setwd("/home/jim/research/bullying/R")
if(answer == "P") setwd("/home/jim/research/palatability_heavydrink/R")
if(answer == "R") setwd("/home/jim/R")
print(list.files(pattern="[.]R"))

I can then select whatever analysis I happen to be working on with a single letter (and newline) and see all of the ".R" and ".Rdata" files in that directory.

Jim