Learn R Programming

W4MRUtils (version 1.0.0)

df_force_numeric: Convert data frame to numeric.

Description

df_force_numeric Converts integer columns of a data frame into numeric.

Usage

df_force_numeric(df, cols = NULL)

Value

The converted data.frame.

Arguments

df

The data frame.

cols

The set of columns to convert to numeric. By default (when set to NULL) all integer columns are converted. Set it to a character vector containing the names of the columns you want to convert, or ton integer vector containing the indices of the columns. Can be used to force conversion of non integer columns.

Examples

Run this code
# Convert an integer data frame
df <- data.frame(a = as.integer(c(1, 4)), b = as.integer(c(6, 5)))
df <- W4MRUtils::df_force_numeric(df)

Run the code above in your browser using DataLab