Learn R Programming

rpg (version 1.6)

stow: Object storage

Description

Serialize and write R objects

Usage

stow(..., tablename = "rpgstow", schemaname = "rpgstow")

list_stowed(tablename = "rpgstow", schemaname = "rpgstow")

retrieve(objnames, tablename = "rpgstow", schemaname = "rpgstow")

delete_stowed(objnames, tablename = "rpgstow", schemaname = "rpgstow")

stow_image(imagename = "rpgimage", schemaname = "rpgstow")

retrieve_image(imagename = "rpgimage", schemaname = "rpgstow")

Arguments

...

a list of objects or object names

tablename

the table for storing objects

schemaname

the schema to use

objnames

a character vector with object names or regular expressions

imagename

a table name for stowing the session image

Details

These functions allow one to write out any R object to a PostgreSQL database and later retrieve them into any R session. The pair stow and retrieve are modeled roughly as save and load.

The contents of ... are handled specially. If a named argument is passed, then the object will be stowed and retrieved with that name. A raw string will not be stowed if it matches the name of any R object; the matching R object will be stowed instead. A vector of strings will however be stowed as is. Object names will be coerced to valid identifiers using make.names. Names must be unique and not collide with any existing object name in the same table.

retrieve assigns the stowed values to the stowed names in the global environment. It will overwrite any variable that has the same name as a stowed object.

The functions retrieve and delete_stowed use regular expression matching as implemented by the PostgreSQL ~ operator.

stow_image and retrieve_image will stow all objects in the current session and retrieve them later. Note that stow_image will overwrite all existing objects stowed within imagename.

See Also

RApiSerialize

Examples

Run this code
# NOT RUN {
createdb("rpgtesting")
connect("rpgtesting")
begin()

stow("test")
list_stowed()
stow("test")
list_stowed()
stow(x = "test")
list_stowed()
x = 1
stow(x)
list_stowed()
stow(y = x)
list_stowed()
rm(x)
retrieve(".*")
print(test)
print(x)
print(y)
delete_stowed(".*")
data(mtcars)
stow(mtcars)
list_stowed()
rm(mtcars)
retrieve("mtcars")
head(mtcars)

rollback()
disconnect()
dropdb("rpgtesting")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab