convert_cols_to_numeric {kim} | R Documentation |
Convert columns to numeric
Description
Check whether each column in a data.table can be converted to numeric, and if so, convert every such column.
Usage
convert_cols_to_numeric(
data = NULL,
classes = "character",
warn_accuracy_loss = TRUE,
print_summary = TRUE,
silent = FALSE
)
Arguments
data |
a data object (a data frame or a data.table) |
classes |
a character vector specifying classes of columns
that will be converted. For example, if |
warn_accuracy_loss |
logical. whether to warn the user if converting character to numeric leads to loss of accuracy. (default = TRUE) |
print_summary |
If |
silent |
If |
Examples
data_frame_1 <- data.frame(a = c("1", "2"), b = c("1", "b"), c = 1:2)
convert_cols_to_numeric(data = data_frame_1)
data_table_1 <- data.table::data.table(
a = c("1", "2"), b = c("1", "b"), c = 1:2)
convert_cols_to_numeric(data = data_table_1)