View source: R/dp_apply_schema.R
dp_apply_schema | R Documentation |
Convert columns of data.frame to their correct types using table schema
dp_apply_schema(
dta,
resource,
convert_categories = c("no", "to_factor", "to_code"),
reorder = TRUE,
...
)
dta |
a |
resource |
an object with the Data Resource of the data set. |
convert_categories |
how to handle columns for which the field
descriptor has a |
reorder |
put the columns in the same order as the fields in the data resource. |
... |
additional arguments are passed on to the |
Converts each column in dta
to the correct R-type using the type
information in the table schema. For example, if the original column type in
dta
is a character vector and the table schema specifies that the field is
of type number, the column is converted to numeric using the decimal
separator and thousands separator specified in the field descriptor (or default values
for these if not).
Returns a copy of the input data.frame with columns modified to match the
types given in de table schema. When reorder = TRUE
columns are put in the
same order as in the data resource with fields not in the data resource put
at the back of the data.frame.
This function calls conversion functions for each of the columns, see
dp_to_number
, dp_to_boolean
, dp_to_integer
,
dp_to_date
. dp_to_datetime
, dp_to_yearmonth
,
and dp_to_string
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.