Description Usage Arguments Value See Also Examples
fread_fwf
takes as basic input a fixed-width filename and its schema and
wraps around fread
from package data.table or around
read_fwf
to provide the contents of the file.
This method is indeed either (i) a wrapper for the function fread
followed by the application of stri_sub
or (ii) a direct wrapper for the
function read_fwf
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | fread_fwf(
filename,
StfwfSchema,
validate = FALSE,
convert = TRUE,
outFormat = "data.table",
perl = FALSE,
...
)
## S4 method for signature 'character,StfwfSchema'
fread_fwf(
filename,
StfwfSchema,
validate = FALSE,
convert = TRUE,
outFormat = "data.table",
perl = FALSE,
encoding = "unknown",
...
)
|
filename |
Character vector of length 1 with the name of the file to read. |
StfwfSchema |
Object of class StfwfSchema with the schema of the file to read. |
validate |
Logical vector of length 1 with default value |
convert |
Logical vector of length 1 with default value |
outFormat |
Character vector of length 1 whose default value is "data.table". Other option is "tibble". |
perl |
Logical vector of length 1 with default value |
... |
Other parameters from |
encoding |
Optional argument with the encoding to be used by fread, by default 'unknown'
(see |
Returns a data.table or a tibble with the contents of the file.
1 2 3 4 5 6 7 8 9 10 11 12 | path <- system.file('extdata', package = 'fastReadfwf')
stSchema <- fastReadfwf::StxlsxToSchema(file.path(path, 'SchemaSNHS.xlsx'), 'stSchema')
# For data.tables
data.DT <- fread_fwf(
file.path(path, 'MicroDataSNHS.txt'), stSchema, outFormat = 'data.table', perl = TRUE)
head(data.DT)
# For tibbles
data.tibble <- fread_fwf(
file.path(path, 'MicroDataSNHS.txt'), stSchema, outFormat = 'tibble')
head(data.tibble)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.