save_problem: Wrapper function to save problem files

Description Usage Arguments Examples

View source: R/data_io.R

Description

Save the input problem to the data_dir directory using the unique ID analysis_name. Either a main problem is saved (if is_folds is FALSE, the default) or a set of fold problems are saved (if is_folds is TRUE). If is_folds is TRUE, the input should be a list with named elements train_list and test_list that contain the fold training and test problems.

Usage

1
save_problem(data_dir, analysis_name, problem, is_folds = F)

Arguments

data_dir

The data directory with problems and results

analysis_name

A unique analysis name (for the input data directory)'

problem

Problem that needs saving

is_folds

Whether this object represents folds

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Generate a dummy problem
problem <- list(x = 1:6,
                Y = rnorm(6))
# Use R's temporary directory as the data directory
data_dir <- tempdir()

# Use 'ex' as the unique analysis ID
analysis_name <- 'ex'

# Check if problem file already exists; should be FALSE
print(file.exists(paste0(data_dir,'problem_ex.rds')))

# Call save_problem to save problem_ex.rds in data_dir
save_problem(data_dir,analysis_name,problem)

# Check if problem file now exists in dir_path; should be TRUE
file.exists(paste0(dir_path,'problem_ex.rds'))  

# Remove dummy problem file from temporary directory
was_successful <- file.remove(paste0(dir_path, 'problem_ex.rds'))

MichaelHoltonPrice/yada documentation built on Sept. 19, 2021, 11:27 p.m.