Stores and load data in various of data format. See 'Details' for limitations.
Value
The normalized path for export_table
, and a
data.table
for import_table
Details
The format 'rds'
, 'h5'
, 'fst'
, 'json'
, and
'yaml'
try to preserve the first-level column attributes. Factors
will be preserved in these formats. Such property does not exist in
'csv'
, 'csv.zip'
formats.
Open-data formats are 'h5'
, 'csv'
, 'csv.zip'
,
'json'
, 'yaml'
. These formats require the table elements to
be native types (numeric, character, factor, etc.).
'rds'
, 'h5'
, and 'fst'
can store large data sets.
'fst'
is the best choice is performance and file size are the major
concerns. 'rds'
preserves all the properties of the table.
Examples
x <- data.table::data.table(
a = rnorm(10),
b = letters[1:10],
c = 1:10,
d = factor(LETTERS[1:10])
)
f <- tempfile(fileext = ".csv.zip")
export_table(x = x, file = f)
y <- import_table(file = f)
str(x)
#> Classes ‘data.table’ and 'data.frame': 10 obs. of 4 variables:
#> $ a: num -0.0886 0.8048 -0.9736 -0.3458 -1.5931 ...
#> $ b: chr "a" "b" "c" "d" ...
#> $ c: int 1 2 3 4 5 6 7 8 9 10
#> $ d: Factor w/ 10 levels "A","B","C","D",..: 1 2 3 4 5 6 7 8 9 10
#> - attr(*, ".internal.selfref")=<externalptr>
str(y)
#> Classes ‘data.table’ and 'data.frame': 10 obs. of 4 variables:
#> $ a: num -0.0886 0.8048 -0.9736 -0.3458 -1.5931 ...
#> $ b: chr "a" "b" "c" "d" ...
#> $ c: int 1 2 3 4 5 6 7 8 9 10
#> $ d: chr "A" "B" "C" "D" ...
#> - attr(*, ".internal.selfref")=<externalptr>
# clean up
unlink(f)