Learn R Programming

erpR (version 0.2.0)

factorall: Factorize one or more variables in a data frame

Description

A convenience function to transform on or more variables of a data frame into factors.

Usage

factorall(x)

Arguments

x
one or more data frame columns to be transformed into factor.

Value

The vectors supplied are transformed into factors. Notice that if a variable is already a factor, it is updated and all unused levels are dropped.

Examples

Run this code

data(iris)

iris2 <- iris[iris$Species!="setosa", ]
levels(iris2$Species)

iris2[,c("Petal.Width", "Species")]<-factorall(iris2[,c("Petal.Width", "Species")])
levels(iris2$Species)
str(iris2)


Run the code above in your browser using DataLab