load_object | R Documentation |
load R object by name
load_object( object, save_date = NULL, objects_path = jamsession_paths()$objects, envir = globalenv(), verbose = TRUE, ... )
object |
|
save_date |
optional character string with a specific date to
use when loading an object. This string is matched with
the |
objects_path |
character vector of one or more file paths to
search for saved R objects. When |
envir |
optional R environment inside which to load the R object.
Note that if an R object already exists in this environment,
it will overwritten without warning. This behavior is intended
by |
verbose |
logical whether to print verbose output |
... |
additional arguments are ignored. |
This function loads the most recently saved R object by name, from a given file path. This mechanism is intended to help share useful R objects across R sessions, especially where it may be helpful to discover R objects by name, and where R objects may continue to be useful over time.
Typically this function is called with the name of one or more saved
objects, and loads the most recent version of each. However, the argument
save_date
can be supplied as a vector, which is recycled for each
saved object, as a method to load a specific version of an object.
This behavior is not intended for routine use, but is available
in rare cases that you may want to inspect previous versions of
an object.
Note that envir
can be used to load the object into a separate
environment, if needed.
invisible name of the R object loaded. It also loads the R object into the environment specified, by default the active global environment .GlobalEnv.
Other jamsession objects:
grep_objects()
,
list_objects()
,
save_object()
my_df <- data.frame(A=LETTERS[1:5], a=letters[1:5]); print(my_df); save_object("my_df"); grep_objects("my_df"); rm(my_df); load_object("my_df"); print(my_df); load_object(grep_objects("my_df")) print(my_df); ###################################### # Load into a separate environment rm(my_df); sep_env <- new.env(); load_object("my_df", envir=sep_env); # this object is not in the current workspace find("my_df"); # you can use get() to see this object print(get("my_df", envir=sep_env)); # or you can attach the environment to use objects inside find("my_df"); attach(sep_env); find("my_df"); # detach when no longer using this environment detach("sep_env"); find("my_df"); ###################################### # example showing two objects stored together my_df2 <- data.frame(B=LETTERS[11:15], b=letters[11:15]); load_object("my_df"); save_object(c("my_df", "my_df2")); grep_objects("my_df2"); loaded <- load_object(grep_objects("my_df2")); # note that it loads two objects print(loaded);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.