replaceVals: User-intended wrapper for single-file replacements

Description Usage Arguments Details Value Note Examples

View source: R/valReplacement.R

Description

The function sends the prepared data.tables to sReplace, receives updated data, displays a list of updated data and of counts of multiple replacements and saves the updated data to disk (see Details).

Usage

1

Arguments

dir

Quoted character of length = 1L describing the path to the directory containing the data and associated lookup file(s), with either forward or double backward slash and no end slash.

...

Not used for default file names "data.csv", "lookup.csv". Otherwise, custom names including file extension, within quotation marks, such as "<data_name>.csv", "<lookup_name>.csv", entered in this order!.

save

Logical, default TRUE: save results to dir. FALSE: display only. See Note below.

Details

The workflow:

Tasks

The function reads the data/lookup pair converting each file to "data.table" class, performs conformance checks on associated lookup, removes uninvolved data columns and non-standard lookup columns. Upon return from sReplace, re-structures updated result in the original format, saves the updated data to dir and displays a one-run named list containing updated data along with counts of duplicated and/or missing values replacements requests.

Messages

The function displays messages and comments regarding the internal workflow. It is recommended reading these messages/comments as first troubleshooting step since they are specific to each file pair and request type. To suppress messages, wrap the function with suppressMessages. The vignette contains definitions of terms.

Value

A one-run named list containing the updated data and multiple replacement counts. Also, csv file saved in the same directory under the name updated_<data_name>using<lookup_name>.

Note

In examples, please leave the function argument save to FALSE. Otherwise, copy all content of the folder "extdata", found in package's root, into a directory on your machine. Use the absolute path to this directory as dir argument (vignette example).

Examples

1
2
3
4
5
6
## Not run: datasets with default name "data.csv", "lookup.csv"

if (interactive()) {
 dir = system.file("extdata", package = "replacer")
 replaceVals(dir, save = FALSE)
 }

replacer documentation built on Sept. 5, 2021, 5:18 p.m.