closure_write | R Documentation |
You can use closure_write()
to save the results of
closure_generate()
on your computer. A message will show the exact
location.
The data are saved in a new folder as four separate files, one for each
tibble in closure_generate()
's output. The folder is named after the
parameters of closure_generate()
.
closure_read()
is the opposite: it reads those files back into R,
recreating the original CLOSURE list. This is useful for later analyses if
you don't want to re-run a lengthy closure_generate()
call.
closure_write(data, path)
closure_read(path)
data |
List returned by |
path |
String (length 1). File path where |
closure_write()
saves the first three tibbles as CSVs, but the
"results"
tibble becomes a Parquet file. This is much faster and takes up
far less disk space — roughly 1% of a CSV file with the same data. Speed
and disk space can be relevant with large result sets.
Use closure_read()
to recreate the CLOSURE list from the folder. One of
the reasons why it is convenient is that opening a Parquet file requires a
special reader. For a more general tool, see
nanoparquet::read_parquet()
.
closure_write()
returns the path to the new folder it created,
closure_read()
returns a list.
The new folder's name should be sufficient to recreate its CLOSURE results. Dashes separate values, underscores replace decimal periods. For example:
CLOSURE-3_5-1_0-90-1-5-up_or_down-5
The order is the same as in closure_generate()
:
closure_generate( mean = "3.5", sd = "1.0", n = 90, scale_min = 1, scale_max = 5, rounding = "up_or_down", # default threshold = 5 # default )
data <- closure_generate(
mean = "2.7",
sd = "0.6",
n = 45,
scale_min = 1,
scale_max = 5
)
# You should write to a real folder instead;
# or just leave `path` unspecified. I use a
# fake folder just for this example.
path_new_folder <- closure_write(data, path = tempdir())
# In a later session, conveniently read the files
# back into R. This returns the original list,
# identical except for floating-point error.
closure_read(path_new_folder)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.