How To: How can I convert a variable in a model formula to a factor or categorical variable?

RevoScaleR formulas support two formula functions for converting categorical variables: 

N() treats a categorical variable as continuous. 
F() treats a continuous variable as categorical. 
F() contains additional arguments low, high, and exclude, which can be included to specify the value of the lowest category, the highest category, and how to handle values outside the specified range. 

This example, which uses sample Census Data shipped with RevoScaleR, simply uses F() to treat the 'age' variable as a factor in the summary formula: 

sampleDataDir <- rxGetOption("sampleDataDir") censusWorkers <- file.path(sampleDataDir, "CensusWorkers.xdf") rxSummary(~ F(age) + sex, data = censusWorkers)
 

For more information on RevoScaleR formula syntax, type ?rxFormula at the Revolution R Enterprise console.   
Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.
Properties

Article ID: 3104258 - Last Review: 10/29/2015 08:12:00 - Revision: 1.0

Revolution Analytics

  • KB3104258
Feedback