Learn R Programming

crunch (version 1.20.0)

toVariable: Generic method for converting objects to Crunch representations

Description

R objects are converted to Crunch objects using the following rules:

Usage

toVariable(x, ...)

# S4 method for character toVariable(x, ...)

# S4 method for numeric toVariable(x, ...)

# S4 method for factor toVariable(x, ...)

# S4 method for Date toVariable(x, ...)

# S4 method for POSIXt toVariable(x, ...)

# S4 method for AsIs toVariable(x, ...)

# S4 method for VariableDefinition toVariable(x, ...)

# S4 method for logical toVariable(x, ...)

# S4 method for CrunchExpr toVariable(x, ...)

Arguments

x

the object

...

additional arguments

Value

a list object suitable for POSTing to the Crunch API. See the API documentation for specifications.

Details

  • Character vectors are converted into Crunch text variables

  • Numeric vectors are converted into Crunch numeric variables

  • Factors are converted to categorical variables

  • Date and POSIXt vectors are converted into Crunch datetime variables

  • Logical vectors are converted to Crunch categorical variables

  • VariableDefinitions are not converted, but the function can still append additional metadata

If you have other object types you wish to convert to Crunch variables, you can declare methods for toVariable