
factorise(data, colNames)
data
of same class as input with specified variables converted to factor
data
and variable names and all of them will be converted to factor.It works for both 'data.frame' and 'data.table', and the output is data of the same class as that of input.
randomise
, rmdupkey
, rmdupobs
# A 'data.frame'
df <- data.frame(x = c(1, 2, 3, 4, 5),
y = c('a', 'b', 'c', 'd', 'e'),
z = c(1, 1, 0, 0, 1))
# Change the class of variables y and z to factors
dfFac <- factorise(data = df, colNames = c('y', 'z'))
Run the code above in your browser using DataLab