Description Usage Arguments Value See Also Examples
setChar
Set the class of each variable in data
to character and the NA
values to empty string.
1 |
data |
It can be a data.table or a tibble. |
Returns a data.table or a tibble
with the content of data
but with all the columns set to character.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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)
data.DT.back <- setChar(data.DT.types)
head(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)
data.tibble.back <- setChar(data.tibble.types)
head(data.tibble.types)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.