Skip to contents

Convert specified columns to factor

Usage

convert2Factor(data, columns)

Arguments

data

The input data frame

columns

The column names to be converted to factors

Value

The modified data frame with specified columns converted to factors

Examples

data <- data.frame( Category1 = c("A", "B", "A", "B"),
                     Category2 = c("X", "Y", "X", "Z"),
                     Value = 1:4,
                     stringsAsFactors = FALSE )
## -- Convert columns to factors
convert2Factor(data, columns = c("Category1", "Category2"))
#>   Category1 Category2 Value
#> 1         A         X     1
#> 2         B         Y     2
#> 3         A         X     3
#> 4         B         Z     4