Learn R Programming

polyreg (version 0.6.3)

misc: Miscellaneous

Description

Utilities

Usage

toFactors(df,cols)

Arguments

df

A data frame.

cols

A vector of column numbers.

Details

The toFactors function converts each df column in cols to a factor, returns new version of df. Should be used on categorical variables stored as integer codes before calling the library's main functions, including getPoly, FSR, or polyFit.

Examples

Run this code
# NOT RUN {
data(prgeng) # US Census engineer wage data 
xy <- prgeng[, c(1:4,6,5)] # Y value (wageinc here) must be last for polyFit() and FSR()
xy <- toFactors(xy, 2:4)  # convert education, occupation, and sex to factors
                          # (don't pass categorical variables as integer codes when fitting)
# }

Run the code above in your browser using DataLab