This function is used to set columns of a data frame of class character or numerical to class factor

Factorize(data, columns)

Arguments

data

A data frame

columns

A character or vector equal to the names of the column(s) of the variables to be set as factors

Value

A the same data frame as data but with the class of the columns column(s) set to factor

Examples


df <- data.frame(X = c(A, B, C),
                 Y = c(a, b, c))
#> Error in data.frame(X = c(A, B, C), Y = c(a, b, c)): object 'A' not found

df <- Factorize(data = df, columns = 'X')
#> Error in data[, columns[i]]: object of type 'closure' is not subsettable

class(df$X)
#> Error in df$X: object of type 'closure' is not subsettable
class(df$Y)
#> Error in df$Y: object of type 'closure' is not subsettable