as_valueType | R Documentation |
Attributes a valueType to an object, that can be a vector, or in a data frame using dplyr::mutate.
as_valueType(x, valueType = "text")
x |
Object to be coerced. Can be a vector. |
valueType |
A character string of the valueType used to coerce x. |
The valueType is a declared property of a variable that is required in certain functions to determine handling of the variables. Specifically, valueType refers to the OBiBa data type of a variable. The valueType is specified in a data dictionary in a column 'valueType' and can be associated with variables as attributes. Acceptable valueTypes include 'text', 'integer', 'decimal', 'boolean', datetime', 'date'. The full list of OBiBa valueType possibilities and their correspondence with R data types are available using valueType_list. The valueType can be used to coerce the variable to the corresponding data type.
The object coerced accordingly to the input valueType.
{
# use madshapR_DEMO provided by the package
dataset <- madshapR_DEMO$dataset_TOKYO
as_valueType(head(dataset$dob),'date')
# as_valueType is compatible with tidyverse philosophy
library(dplyr)
mtcars %>% mutate(cyl = as_valueType(cyl,'integer')) %>% head()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.