Use a spreadsheet to create files for use with the testthat package.

create_testfile(
  ss,
  sheet,
  manipulator = NULL,
  filename = NULL,
  filepath = NULL,
  overwrite = FALSE
)

Arguments

ss

dribble or filepath.

sheet

character (vector). The names of the sheets to be read.

manipulator

a function that manipulates the testdata once it has been read from the spreadsheet

filename

character (vector). The default is testsheet_<sheet>.R. The number of given filenames must match the length of testdata.

filepath

character. The defallt is the current working directory

overwrite

boolean. The default is FALSE.

Examples

ss_path <- testsheets_example("excel") drop_param_y <- function(testdata) { testdata <- testdata %>% dplyr::select(-dplyr::starts_with("param_y")) } filename <- "testsheet_sum_x_only.R" create_testfile(ss_path, sheet = "sum", manipulator = drop_param_y, filename=filename)
#> A file /Users/nicolebrewer/Repos/nicole-brewer-github/testsheets/docs/reference/testsheet_sum_x_only.R already exists. Use the option `overwrite = TRUE` to overwrite it.