Skip to contents

Shorthand to quickly clear console, clear environment, set working directory, load files

Usage

refresh(setwd = NULL, source = c(), load = c(), clearPkgs = FALSE)

Arguments

setwd

OPTIONAL. set working directory

source

OPTIONAL. source in file(s)

load

OPTIONAL. load in Rdata file(s)

clearPkgs

clear previously loaded packages

Value

cleared environment and set directory

Details

The purpose of this function is provide a one-line code to clear the console, clear the environment, set working directory to a specified path, source in various files into the current file, and load RData files into the current environment. The first process in the sequence of events is to clear the environment. Then the working directory is set, prior to inclusion of various files and RData. With the directory being set first, the path to the sourced in or RData files will not need to be appended to the file name. See examples.

Examples

# \donttest{
if(interactive()){
#exactly like the clean function
#simply clear environment, clear console and devices
quickcode::refresh()

#clear combined with additional arguments
quickcode::refresh(
  clearPkgs = FALSE
) #also clear all previously loaded packages if set to TRUE

quickcode::refresh(
  setwd = "/home/"
) #clear env and also set working directory


quickcode::refresh(
  source = c("/home/file1.R","file2")
) #clear environment and source two files into current document


quickcode::refresh(
  setwd = "/home/",
  source = c("file1","file2")
) #clear environment, set working directory and source 2 files into environment


quickcode::refresh(
  setwd = "/home/",
  source="file1.R",
  load="obi.RData"
) #clear environment, set working directory, source files and load RData

}
# }