stow: Object storage

Description Usage Arguments Details Author(s) See Also Examples

Description

Serialize and write R objects

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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.

Author(s)

Timothy H. Keitt

See Also

RApiSerialize

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
## Not run: 
system("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()
system("dropdb rpgtesting")
## End(Not run)

rpg documentation built on May 2, 2019, 5:49 p.m.