dpapplyschema: Convert columns of data.frame to their correct types using...

View source: R/dpapplyschema.R

dpapplyschemaR Documentation

Convert columns of data.frame to their correct types using table schema

Description

Convert columns of data.frame to their correct types using table schema

Usage

dpapplyschema(dta, resource, to_factor = FALSE, ...)

Arguments

dta

a data.frame or data.table.

resource

an object with the Data Resource of the data set.

to_factor

convert columns to factor if the field descriptor a codelist field for the column.

...

additional arguments are passed on to the to_<fieldtype> functions (e.g. to_number).

Details

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).

See Also

This function calls conversion functions for each of the columns, see to_number, to_boolean, to_integer, and to_date.


djvanderlaan/datapackage documentation built on March 18, 2024, 4:57 p.m.