add_synthetic: Add synthetic data to WORCS project

Description Usage Arguments Value See Also Examples

View source: R/add_synthetic.R

Description

This function adds a user-specified synthetic data resource for public use to a WORCS project with closed data.

Usage

1
2
3
4
5
6
7
8
add_synthetic(
  data,
  synthetic_name = paste0("synthetic_", original_name),
  original_name,
  worcs_directory = ".",
  verbose = TRUE,
  ...
)

Arguments

data

A data.frame containing the synthetic data.

synthetic_name

Character, naming the file synthetic data should be written to. By default, prepends "synthetic_" to the original_name.

original_name

Character, naming an existing data resource in the WORCS project with which to associate the synthetic data object.

worcs_directory

Character, indicating the WORCS project directory to which to save data. The default value "." points to the current directory.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# 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)

worcs documentation built on Feb. 2, 2021, 5:13 p.m.