Description Usage Arguments Details Value Examples
View source: R/readOrMakeObj.R
Read object from file or make object
1 2 | readOrMakeObj(s_file, makeObj = NULL, ..., b_always_make_obj = FALSE,
b_message_time = FALSE)
|
s_file |
string of file where object is retreaved or saved see details. Must end in .rds. |
makeObj |
function. |
... |
additional parameters to be passed to |
b_always_make_obj |
boolean if true |
b_message_time |
boolean, should time ellapsed by messaged. |
It is common to produce large objects which take a long time to execute as part of a script.
In some cases we would like to retreave these objects but in other cases they need to be constructed again.
This function helps with that processes. If s_file exist and b_always_make_obj
is false object will be extracted.
If s_file does not exist or b_always_make_obj
object will be created and saved to s_file
.
either the object extracted from s_file
or created by makeObj
. See details.
1 2 3 4 5 6 7 8 9 | # create a random vector, assign it to v_n_random and save it to file.rds
v_n_random <- readOrMakeObj("file.rds", rnorm, n = 1000000,
b_always_make_obj = TRUE, b_message_time = TRUE )
# retreave vector changing a parameter
v_n_random_2 <- readOrMakeObj("file.rds", rnorm, n = 100,
b_always_make_obj = FALSE, b_message_time = TRUE )
length(v_n_random_2)
# 1000000 not 100
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.