closed_data: Use closed data in WORCS project

Description Usage Arguments Value See Also Examples

View source: R/save_load.R

Description

This function saves a data.frame as a .csv file (using write.csv), stores a checksum in '.worcs', appends the .gitignore file to exclude filename, and saves a synthetic copy of data for public use. To generate these synthetic data, the function synthetic is used.

Usage

1
2
3
4
5
6
7
8
closed_data(
  data,
  filename = paste0(deparse(substitute(data)), ".csv"),
  codebook = paste0("codebook_", deparse(substitute(data)), ".Rmd"),
  worcs_directory = ".",
  synthetic = TRUE,
  ...
)

Arguments

data

A data.frame to save.

filename

Character, naming the file data should be written to. By default, constructs a filename from the name of the object passed to data.

codebook

Character, naming the file the codebook should be written to. An 'R Markdown' codebook will be created and rendered to github_document ('markdown' for 'GitHub'). By default, constructs a filename from the name of the object passed to data, adding the word 'codebook'. Set this argument to NULL to avoid creating a codebook.

worcs_directory

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

synthetic

Logical, indicating whether or not to create a synthetic dataset using the synthetic function. Additional arguments for the call to synthetic can be passed through ....

...

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
old_wd <- getwd()
test_dir <- file.path(tempdir(), "data")
dir.create(test_dir)
setwd(test_dir)
worcs:::write_worcsfile(".worcs")
df <- iris[1:3, ]
closed_data(df, codebook = NULL)
setwd(old_wd)
unlink(test_dir, recursive = TRUE)

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