| as.Text {crunch} | R Documentation | 
as.* methods for variables
Description
Use the as.* family of functions to make a derived copy of a variable that has been converted into a new type.
Usage
as.Text(x, ...)
as.Numeric(x)
as.Categorical(x, ...)
as.Datetime(x, format = "%Y-%m-%d %H:%M:%S", resolution, offset)
## S4 method for signature 'CrunchVariable'
as.Numeric(x)
## S4 method for signature 'CrunchVariable'
as.Text(x, format)
## S4 method for signature 'CrunchVariable'
as.Categorical(x, format)
## S4 method for signature 'CrunchVariable'
as.Datetime(x, format = "%Y-%m-%d %H:%M:%S", resolution, offset)
## S3 method for class 'CrunchVariable'
as.double(x, ...)
## S3 method for class 'CrunchVariable'
as.character(x, ...)
## S4 method for signature 'CrunchExpr'
as.Numeric(x)
## S4 method for signature 'CrunchExpr'
as.Text(x, format)
## S4 method for signature 'CrunchExpr'
as.Categorical(x, format)
## S4 method for signature 'CrunchExpr'
as.Datetime(x, format = "%Y-%m-%d %H:%M:%S", resolution, offset)
## S3 method for class 'CrunchExpr'
as.double(x, ...)
## S3 method for class 'CrunchExpr'
as.character(x, ...)
Arguments
| x | a Crunch variable to derive and convert to a new type | 
| ... | additional arguments for  | 
| format | for  | 
| resolution | for  | 
| offset | for  | 
Details
Each type of Crunch variable (text, numeric, categorical, etc.) has an as.*
function (as.Text, as.Numeric, and as.Categorical respectively) that
takes the input given as x, and makes a new derived variable that is now of
the type specified. See below for detailed examples.
For as.Text and as.Numeric, aliases to the R-native functions
as.character and as.numeric are provided for convenience.
Value
a CrunchExpr to be used as the derivation
Examples
## Not run: 
# ds$v1 is of type Text
is.Text(ds$v1)
# [1] TRUE
# that has strings of numbers
as.vector(ds$v1)
# [1] "32"   "8"    "4096" "1024"
# convert this to a numeric variable with the alias `v1_numeric`
ds$v1_numeric <- as.Numeric(ds$v1)
# the values are the same, but are now numerics and the type is Numeric
as.vector(ds$v1_numeric)
# [1]   32    8 4096 1024
is.Numeric(ds$v1_numeric)
# [1] TRUE
# this new variable is derived, so if new data is appended or streamed, the
# new rows of data will be updated.
is.derived(ds$v1_numeric)
# [1] TRUE
## End(Not run)