Description Usage Arguments Details Examples
nwsVariable
creates a variable in an R workspace that mirrors
a variable in a netWorkSpace. This allows standard R operations
(get, assign) to be used to share data between R programs running on
different machines.
1 2 | ## S4 method for signature 'netWorkSpace'
nwsVariable(.Object, xName, mode=c('fifo','lifo','multi','single'),env=parent.frame(),force=FALSE,quietly=FALSE)
|
.Object |
a netWorkSpace class object. |
xName |
name of variable to be declared. |
mode |
mode of the variable, see details. |
env |
environment in which to define active binding. |
force |
logical; if |
quietly |
logical; if |
nwsVariable
is built on top of the R makeActiveBinding
function. It is experimental, but we have found that it is very
useful for introducing people to the concept of netWorkSpace
variables. It's not clear that this API is ever preferable to
nwsStore
, nwsFetch
, nwsFind
for real programs,
however.
The mode
of the variable controls what happens when a variable
is accessed. If the mode
is 'single'
, then all accesses use
the nwsFind
operation. If the mode
is 'fifo'
,
'lifo'
, or 'multi'
, then all accesses use the
nwsFetch
operation.
Assigning a value to an nwsVariable
always uses the
nwsStore
operation.
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 | ## Not run:
# create a netWorkSpace
ws = netWorkSpace('nws example')
# create a variable in the local R workspace that is linked to
# a netWorkSpace variable
nwsVariable(ws, 'x', 'single')
x <- 0
x <- 999 # overwrites the 0
x <- 3.14159 # overwrites the 999
x # returns 3.14159
x # returns 3.14159
x # returns 3.14159
# create a 'fifo' mode variable
nwsVariable(ws, 'message', 'fifo')
message <- 1
message <- 2
message <- 3
message # returns 1
message # returns 2
message # returns 3
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.