Description Usage Arguments Details Value Octave Documentation for assignin Note Examples
o_assign
assigns a variable in Octave.
o_assignin
is an alias for o_assign
.
o_get
fetches Octave variables/functions and possibly rename them on
the fly with the provided argument names when present.
Functions are returned as objects of class OctaveFunction
,
that can be called subsequently (see the examples).
1 2 3 4 5 |
... |
variables to assign in Octave global context for |
unlist |
a logical that specifies it single variables should be returned as a single value (default), or as a list. |
rm.ans |
a logical that indicates if the automatic Octave variable |
pattern |
regular expression used to filter the requested variable names. Only names matching the pattern are returned. |
o_assign
assigns the variables using the arguments' names if present.
Variables can also be specified as a single named list or environment.
Single variable assignments can also be specified as o_assign('a', 10)
.
See Examples for more details.
o_assign
returns invisibly the names of the assigned variables.
o_get
returns a list of the retrieved variable/object. If
unlist=TRUE
and a single – not re-named – variable/object is requested then
only its value is returned.
[Generated from Octave-\Sexpr{RcppOctave::o_version()} on \Sexpr{Sys.time()}]
The function o_get
is the equivalent of R get
function and is not related to the Octave function get
which returns
graphics' properties.
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | ## directly assign variables
o_assign(a=1, b=2, c=matrix(1:9, 3))
# retrieve their values
o_get()
## assign a variable for each element in a list
x <- list(a=10, b=20, c=matrix(101:109, 3))
o_assign(x)
o_get()
## assign the content of an environment
e <- list2env(setNames(x, paste('env', names(x), sep='_')))
o_assign(e)
o_get(pattern="^env_")
# get all currently defined variables
o_get()
# by default, the automatic variable `ans` is not returned but might be there
# from unstored previous computation
o_eval('svd(rand(3,3))')
o_get()
o_get(rm.ans=FALSE)
# load some variables
x <- list(b=1, c=3, d=matrix(1:9, 3))
o_assign(x)
# re-fetch all variables
o_get()
# only fetch specific variables
o_get('b')
o_get('b', 'c')
# one can rename variables on the fly
o_get(a='b', 'c')
o_get(c(othername='b'))
o_get(c(othername='b', 'c'))
# fetching using a regular expression
o_assign( setNames(1:3, paste("test", 1:3, sep='_')))
o_get()
o_get(pattern="^test")
# works with functions
f <- o_get('svd')
f
f(matrix(1:9,3))
f(matrix(1:9,3), argout=3)
# an error is thrown in the case of multiple matches (the alternatives are shown)
o_clear()
o_assign(aaa=1, ab=2)
try(o_get('a'))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.