save_object | R Documentation |
save R object to a central location
save_object( object_list, save_date = jamba::getDate(), objects_path = jamsession_paths()$objects, object_notes_list = "", do_file_info = FALSE, object_suffix = ".RData", envir = globalenv(), verbose = TRUE, ... )
object_list |
|
save_date |
character date string to use when naming the file.
By default, the current date is used via the function
|
objects_path |
character vector of one or more file paths to
search for saved R objects. When |
object_notes_list |
|
do_file_info |
|
object_suffix |
|
envir |
the environment from which to obtain the R object. |
verbose |
|
... |
additional arguments are ignored. |
This function saves a single R object to an .RData file,
versioned by date using jamba::getDate()
,
so it can be discovered and re-used by other R sessions.
When multiple objects should be saved together, the recommended method:
create a list object that includes these objects
save this list object using save_object()
However, when multiple objects are supplied in object_list
,
the object names are concatenated with "-"
and this string
is used to define the saved R object file. For example
save_object(c("df1", "df2"))
will save an R object file
using the string "df1-df2"
. When this file is loaded,
two R objects are loaded into the environment: "df1"
and "df2"
.
While not always ideal, this mechanism may be more convenient,
and it is left for the user to decide which is best.
Note that objects_path
may contain multiple directories, and
when this occurs, the directories are attempted in order. The
R object is saved to the first directory that allows the file
to be saved successfully.
character
string with the file path where the
R object data is stored.
Other jamsession objects:
grep_objects()
,
list_objects()
,
load_object()
temp_objects_path <- file.path(tempdir(), "R-objects"); if (!dir.exists(temp_objects_path)) { dir.create(temp_objects_path) } example_df <- data.frame(name=LETTERS[1:5], values=letters[1:5]) save_object("example_df", objects_path=temp_objects_path) grep_objects("example", objects_path=temp_objects_path) list_objects(objects_path=temp_objects_path)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.