-
Notifications
You must be signed in to change notification settings - Fork 0
Functions
Thomas J. Brailey edited this page May 7, 2020
·
4 revisions
- R functions go in their own individual .r file.
- The name of the file should be the same as the name of the function
- Functions should have documentation using roxygen headers
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...