convert_to_numeric {cleanepi} | R Documentation |
Convert columns into numeric
Description
When this function is invoked without specifying the column names to be
converted, the target columns are the ones returned by the scan_data()
function. Furthermore, it identifies columns where the proportion of numeric
values is at least twice the percentage of character values and performs the
conversion in them. The function internally makes call of the main function
from the numberize package.
Usage
convert_to_numeric(data, target_columns = NULL, lang = c("en", "fr", "es"))
Arguments
data |
The input |
target_columns |
A |
lang |
A |
Value
A <data.frame>
or <linelist>
wherein all the specified
or detected columns have been transformed into numeric format after the
conversion process.
Examples
data <- readRDS(
system.file("extdata", "messy_data.RDS", package = "cleanepi")
)
# convert the 'age' column into numeric
dat <- convert_to_numeric(
data = data,
target_columns = "age",
lang = "en"
)
# print the report from this operation
print_report(data = dat, "converted_into_numeric")