Learn R Programming

nws (version 1.7.0.1)

nwsStore: Associate a Value with a Variable in netWorkSpace

Description

Store value associated with a variable in the shared netWorkSpace.

Usage

"nwsStore"(.Object, xName, xVal)

Arguments

.Object
a netWorkSpace class object.
xName
character string to be used as the name of the stored variable.
xVal
value to be stored.

Details

The nwsStore method associates the value xVal with the variable xName in the shared netWorkSpace .Object, thereby making the value available to all the distributed R processes. If a mode has not already been set for xName, 'fifo' will be used (see nwsDeclare).

Note that, by default ('fifo' mode), nwsStore is not idempotent: repeating nwsStore (nws, xName, xVal) will add additional values to the set of values associated with the variable named xName. See the examples below for details.

See Also

nwsDeclare

Examples

Run this code
## Not run: 
# ws <- netWorkSpace('nws example')
# 
# # To store value 5 bound to variable 'x' on the netWorkSpace 'ws'
# # (If 'x' was declared, then its mode is inherited, 
# # otherwise 'x' uses the default mode 'fifo')
# nwsStore(ws, 'x', 5)
# 
# # store 10 values associate with variable y to the netWorkSpace
# for (i in 1:10)
#   nwsStore(ws, 'y', i)
# 
# # retrieve 10 values associate with variable y from the netWorkSpace
# for (i in 1:10)
#   print(nwsFetch(ws, 'y'))
# ## End(Not run)

Run the code above in your browser using DataLab