View source: R/valReplacement.R
replaceVals | R Documentation |
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 updated data to disk (see Details).
replaceVals(dir, ..., save = TRUE)
dir |
Quoted character of length = 1 describing the path to the directory containing the data and associated lookup files, with either forward or double backward slash and no end slash (e.g. "C:/path/to/directory"). |
... |
Not used when file names are "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. |
The workflow:
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.
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.
A named list containing updated data and multiple replacement counts. Also, a csv file saved in the same directory, under the name updated_<data_name>using<lookup_name>.csv.
In examples, please leave argument save to FALSE. Otherwise, copy all content of folder "extdata" found in the installed package root into a directory on your machine. Use the absolute path to this directory as dir argument.
bReplace, sReplace
## Not run: datasets with default names "data.csv", "lookup.csv" located in *dir* if (interactive()) { dir = system.file("extdata", package = "replacer") replaceVals(dir, save = FALSE) ## no messages (not recommended!) suppressMessages(replaceVals(dir, save = FALSE)) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.