# ---- fst ----------------------------------------------------------------
f <- tempfile(fileext = ".fst")
x <- data.frame(
a = 1:10,
b = rnorm(10),
c = letters[1:10]
)
io_write_fst(x, con = f)
# default reads in proxy
io_read_fst(f)
# load as data.table
io_read_fst(f, "data_table")
# load as data.frame
io_read_fst(f, "data_frame")
# get header
io_read_fst(f, "header_only")
# clean up
unlink(f)
# ---- json ---------------------------------------------------------------
f <- tempfile(fileext = ".json")
x <- list(a = 1L, b = 2.3, c = "a", d = 1+1i)
# default is serialize
io_write_json(x, f)
io_read_json(f)
cat(readLines(f), sep = "\n")
# just values
io_write_json(x, f, serialize = FALSE, pretty = FALSE)
io_read_json(f)
cat(readLines(f), sep = "\n")
# clean up
unlink(f)
# ---- Matlab .mat --------------------------------------------------------
if (FALSE) {
f <- tempfile(fileext = ".mat")
x <- list(a = 1L, b = 2.3, c = "a", d = 1+1i)
# save as MAT 5.0
io_write_mat(x, f)
io_read_mat(f)
# require setting up Python environment
io_read_mat(f, method = "pymatreader")
# MAT 7.3 example
sample_data <- ieegio_sample_data("mat_v73.mat")
io_read_mat(sample_data)
# clean up
unlink(f)
}
# ---- yaml ---------------------------------------------------------------
f <- tempfile(fileext = ".yaml")
x <- list(a = 1L, b = 2.3, c = "a")
io_write_yaml(x, f)
io_read_yaml(f)
# clean up
unlink(f)
Run the code above in your browser using DataLab