Conditionally convert vectors to factors
A generic function and several instances for creating factors from other sorts of data. The primary use case is for vectors that contain few unique values and might be better considered as factors. When applied to a data frame, this is applied to each variable in the data frame.
factorize(x, ...) ## Default S3 method: factorize(x, ...) ## S3 method for class 'numeric' factorize(x, max.levels = 5L, ...) ## S3 method for class 'character' factorize(x, max.levels = 5L, ...) ## S3 method for class 'data.frame' factorize(x, max.levels = 5L, ...) factorise(x, ...)
x |
an object |
... |
additional arguments (currently ignored) |
max.levels |
an integer. Only convert if the number of unique values is no
more than |
data(KidsFeet, package="mosaicData") str(KidsFeet) factorize(KidsFeet$birthyear) str(factorize(KidsFeet)) # alternative spelling str(factorise(KidsFeet))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.