Learn R Programming

OpasnetUtils (version 1.3)

objects: Server side shared R objects

Description

Library for using R objects (like ovariables.) stored in Opasnet R server. Also includes basic encryption and decryption functionality for R objects.

Usage

objects.encode(obj, key)
objects.decode(eobj, key)
objects.get(token, print_names = TRUE)
objects.latest(page_ident, code_name, verbose = FALSE, ...)
objects.put(..., list = character())
objects.store(..., list = character(), verbose = FALSE)

Arguments

obj

Any R object.

eobj

An encoded object returned by objects.encode function.

key

Key string to encode or decode objects. Must be 16,32 or 64 characters in length.

token

R-tools run token string to identify a stored object on Opasnet R server.

print_names

if TRUE prints the names of all the downloaded objects (sets load(verbose = TRUE))

page_ident

Opasnet Media Wiki page identifier (e.g. op_en1390).

code_name

Name of the R code block in Opasnet Media Wiki (the name argument in rcode tag).

verbose

Flag to set more verbose output (for debug purposes).

Objects will be passed straight to R core save function. In case of objects.latest … are passed on to objects.get.

list

List will be passed straight to R core save function.

Value

objects.encode

Returns encoded object to be decoded with objects.decode and given key.

objects.decode

Returns decoded object, as it was before encoding with objects.encode.

objects.get

Returns object or objects stored to Opasnet R server.

objects.latest

Returns object or objects stored to Opasnet R server.

objects.put

No return value.

objects.store

Returns token to identify stored objects on R server.

Details

The main purpose of this library is to provide means to store R objects to Opasnet R server for later use. This is specifically useful and embraced in Opasnet R ecosystem where this library is mainly used for storing and fetching ovariables. Storing objects is currently only possible within Opasnet Media Wiki environments (using R code inside rcode tags), but reading objects stored by running code within public wikis is also possible from local R-installation.

Besides object storing, this library provides basic functionality to encode and decode R objects. This is done by using R base serialization functions and digest library. Objects given to objects.encode will be encoded by using AES function in "ECB" mode. Longer key (16, 32 or 64 characters) obviously means more secured encryption too. Same key must be used for both encryption and decryption.

See also: http://en.opasnet.org/

See Also

load save serialize AES

Examples

Run this code

# Within Opasnet only! Let's assume that the (en.opasnet.org) page identifier - 
# where to code is - would be "Op_en1390" and code name "objs_save_test".
x <- stats::runif(20)
y <- list(a = 1, b = TRUE, c = "Jeah baby jeah!")

objects.store(x, y)

# Fetching can be done also from local R installation.

objects.latest("Op_en1390","objs_save_test")

print(x)
print(y)

# Object encrypt and decrypt

key <- "1234567890abcdef"

eobj <- objects.encode(y, key)
print(eobj)
obj <- objects.decode(eobj, key)
print(obj)

Run the code above in your browser using DataLab