View source: R/prepare_input_data.R
| prepare_input_data | R Documentation |
Converts common tabular objects to a base data.frame, and if normalize = TRUE
it applies light, conservative value normalization:
Converts common date/time strings to POSIXct (best-effort across several formats)
Converts percent-like character columns (e.g. "85%") to numeric (85)
Maps a configurable set of "NA-like" strings to NA, while keeping common survey
responses like "not applicable" or "prefer not to answer" as real levels
Normalizes yes/no character columns to an ordered factor c("no","yes")
prepare_input_data(
data,
normalize = TRUE,
na_strings = c("", "NA", "N/A", "na", "No data", "no data"),
keep_as_levels = c("not applicable", "prefer not to answer", "unsure"),
percent_detect_threshold = 0.6,
datetime_formats = c("%m/%d/%Y %H:%M:%S", "%m/%d/%Y %H:%M",
"%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M", "%Y-%m-%dT%H:%M:%S",
"%Y-%m-%dT%H:%M", "%m/%d/%Y", "%Y-%m-%d")
)
data |
An object coercible to |
normalize |
Logical, run value normalization step (default |
na_strings |
Character vector that should become |
keep_as_levels |
Character vector that should be kept as values (not |
percent_detect_threshold |
Proportion of non-missing values that must contain |
datetime_formats |
Candidate formats tried (in order) when parsing date-times strings.
The best-fitting format (most successful parses) is used. Defaults cover
|
A base data.frame.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.