Learn R Programming

dataPreparation (version 0.1)

setColAsCharacter: Set columns as character

Description

Set as character a column (or a list of columns) from a data.table

Usage

setColAsCharacter(dataSet, cols, verbose = TRUE)

Arguments

dataSet

Matrix, data.frame or data.table

cols

a list of colnames of dataSet (or just one) to transform into characters

verbose

should the function log (logical, default to TRUE)

Value

dataSet (as a data.table), with specified columns set as character.

Examples

Run this code
# NOT RUN {
# Build a fake data.frame
dataSet <- data.frame(numCol = c(1, 2, 3), factorCol = as.factor(c("a", "b", "c")))

# Set numCol and factorCol as character
dataSet <- setColAsCharacter(dataSet, cols = c("numCol", "factorCol"))
# }

Run the code above in your browser using DataLab