Description Usage Arguments Value See Also Examples
setTypes
Set the types in the schema
as class of
each variable in data
.
1 2 3 4 5 6 7 |
data |
It can be a data.table or a tibble with all its columns of class character. |
StfwfSchema |
Object of class StfwfSchema with the schema
used to read the object |
Returns a data.table or a tibble
with the content of data
but with the columns set to the class corresponding
to the types in StfwfSchema.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | path <- system.file('extdata', package = 'fastReadfwf')
stSchema <- fastReadfwf::StxlsxToSchema(file.path(path, 'SchemaSNHS.xlsx'), 'stSchema')
# For data.tables
data.DT.char <- fread_fwf(
file.path(path, 'MicroDataSNHS.txt'), stSchema, validate = FALSE, convert = FALSE,
outFormat = 'data.table', perl = TRUE)
data.DT.types <- setTypes(data.DT.char, stSchema)
str(data.DT.types)
# For tibbles
data.tibble.char <- fread_fwf(
file.path(path, 'MicroDataSNHS.txt'), stSchema, validate = FALSE, convert = FALSE,
outFormat = 'tibble')
data.tibble.types <- setTypes(data.tibble.char, stSchema)
str(data.tibble.types)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.