ufs (version 0.2.0)

massConvertToNumeric: Converting many dataframe columns to numeric

Description

This function makes it easy to convert many dataframe columns to numeric.

Usage

massConvertToNumeric(dat, byFactorLabel = FALSE,
  ignoreCharacter = TRUE, stringsAsFactors = FALSE)

Arguments

dat

The dataframe with the columns.

byFactorLabel

When converting factors, whether to do this by their label value (TRUE) or their level value (FALSE).

ignoreCharacter

Whether to convert (FALSE) or ignore (TRUE) character vectors.

stringsAsFactors

In the returned dataframe, whether to return string (character) vectors as factors or not.

Value

A data.frame.

Examples

Run this code
# NOT RUN {
### Create a dataset
a <- data.frame(var1 = factor(1:4),
                var2 = as.character(5:6),
                stringsAsFactors=FALSE);

### Ignores var2
b <- ufs::massConvertToNumeric(a);

### Converts var2
c <- ufs::massConvertToNumeric(a,
                               ignoreCharacter = FALSE);
# }

Run the code above in your browser using DataCamp Workspace