Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.   

↑ Back to the top


Keywords: kb

↑ Back to the top

Article Info
Article ID : 3104258
Revision : 1
Created on : 1/7/2017
Published on : 10/29/2015
Exists online : False
Views : 77