| factorise | R Documentation |
Put character vectors, columns of a data.frame or list elements as factor if they are character strings
or optionally if they are logicals
factorise(x, logicals = FALSE, ...) ## Default S3 method: factorise(x, logicals = FALSE, ...) ## S3 method for class 'character' factorise(x, logicals = FALSE, ...) ## S3 method for class 'data.frame' factorise(x, logicals = FALSE, ...) ## S3 method for class 'list' factorise(x, logicals = FALSE, ...)
x |
a character vector, a data.frame or a list |
logicals |
logical indicating if logical vectors should also be converted to factors. Defaults to FALSE. |
... |
optional arguments passed on to the methods |
The updated x vector/data.frame or list where the character vectors or optionally logical elements are converted to factors
as.factor, factor
x <- data.frame(x = 1:4, y = LETTERS[1:4], b = c(TRUE, FALSE, NA, TRUE), stringsAsFactors=FALSE) str(factorise(x)) str(factorise(x, logicals = TRUE)) str(factorise(list(a = LETTERS, b = 1:10, c = pi, d = list(x = x))))