Learn R Programming

labdsv (version 2.1-0)

factorize: Change Character Vectors in Data.frames to Factors

Description

Looks at each column in a data.frame, and converts character vector columns to factors.

Usage

factorize(df)

Value

Returns a data.frame where every character column has been converted to a factor

Arguments

df

a data.frame

Author

David W. Roberts droberts@montana.edu

Details

The function simply scans each column in a data.frame looking for character vector columns. For each character column it calls the ‘factor()’ function to convert the column to a factor.

See Also

defactorize

Examples

Run this code
data(brycesite)
brycesite <- defactorize(brycesite)
brycesite$quad[brycesite$quad=='bp'] <- 'BP'
brycesite <- factorize(brycesite)

Run the code above in your browser using DataLab