'rv' implements (loosely) a replacement for the standard numeric and logical classes.
A numeric or logical vector is just a special case of the more general random vector data type (same would apply for the complex data type but this isn't implemented).
To implement the package right, we need certain functions to work completely with
random vectors and basically `fool' R into believing that the rv
objects are
just as good as the standard R data types.
For example, is.atomic
should return TRUE
for rv
objects,
and c(1, rvnorm(1))
should dispatch the c.rv
method. This is not possible, unfortunately,
without replacing some of the "primitive" generic and non-generic functions.
If everything were generic, we could re-define what 'numeric' means for example.
This isn't possible (for obvious efficiency
and compatibility reasons) so we need to do some surgery, replacing
standard functions with special ones that check whether a given argument is
an rv object or not, and then choose the right function to work on the arguments
(a primitive kind of a method dispatch mechanism).
For examples see is.atomic
, c
, var
(for which we have implemented a generic replacement.)
Unfortunately even this may not make rv fully compatible.
Thus we need a system to undo a function replacement.
The only use of this function - currently - is rvcompatibility(1)
which restores all functions in the base backage. Example: `c(...)
'.
Inserting numeric/logical objects into an rv objects still works,
but inserting an rv object into a plain numeric/logical vector will not work,
for example.
NOTE. When the package rv is detached (you can do it simply with detachrv()
),
all functions that were replaced upon attaching the package are immediately restored.
- level 0
{Default: In particular, makes sure that assignment of an rv object into a component of numeric object is allowed (returning an rv object)}
- level 1
{More compatible with existing programs. In particular, assignment of an rv object into a component of numeric object is not possible}