Skip to content

Functions

Thomas J. Brailey edited this page May 7, 2020 · 4 revisions

Writing Functions

fromscratch

For long functions that create and output a dataframe, it may make sense to give it the parameter "fromscratch" to give the option of loading the most recent output from this function. This code will likely look like this:

if(fromscratch){
  #### ...loading code...
  saveRDS(df_name,
    paste0(here::here(), "/inst/extdata/","save_name.rds"))
} else {
  df_name <- readRDS(system.file("extdata", "save_name.rds", package = "package_name"))
}

#### ...doing stuff code...

Clone this wiki locally