add_synthetic {worcs} | R Documentation |
Add synthetic data to WORCS project
Description
This function adds a user-specified synthetic data resource for public use to a WORCS project with closed data.
Usage
add_synthetic(
data,
synthetic_name = paste0("synthetic_", original_name),
original_name,
worcs_directory = ".",
verbose = TRUE,
...
)
Arguments
data |
A |
synthetic_name |
Character, naming the file synthetic data should be
written to. By
default, prepends |
original_name |
Character, naming an existing data resource in the WORCS
project with which to associate the synthetic |
worcs_directory |
Character, indicating the WORCS project directory to
which to save data. The default value |
verbose |
Logical. Whether or not to print status messages to the console. Default: TRUE |
... |
Additional arguments passed to and from functions. |
Value
Returns NULL
invisibly. This
function is called for its side effects.
See Also
open_data closed_data save_data
Examples
# Create directory to run the example
old_wd <- getwd()
test_dir <- file.path(tempdir(), "add_synthetic")
dir.create(test_dir)
setwd(test_dir)
worcs:::write_worcsfile(".worcs")
# Prepare data
df <- iris[1:3, ]
# Run closed_data without synthetic
closed_data(df, codebook = NULL, synthetic = FALSE)
# Manually add synthetic
add_synthetic(df, original_name = "df.csv")
# Remove original from file and environment
file.remove("df.csv")
rm(df)
# See that load_data() now loads the synthetic file
load_data()
# Cleaning example directory
setwd(old_wd)
unlink(test_dir, recursive = TRUE)
[Package worcs version 0.1.14 Index]