'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. This is not possible, unfortunately,
without replacing some of the "primitive" non-generic functions.
Everything would be fine if everything were generic and we could re-define
what 'numeric' means for example. This isn't possible (for obvious efficiency
and compatibility reasons I think) 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).
Unfortunately even this will not make rv fully compatible.
Especially, the function "[<-"
, even when replaced, will not work with
all programs. Thus we need a system to undo a function replacement.
If you experience a weird error (esp. working with assignment to a factor vector)
check rvcompatibility(1)
and re-run your program. The only use of this function - currently - is rvcompatibility(1)
which restores the function "[<-"
in the base package.
Inserting numeric/logical objects into an rv objects still works,
but inserting an rv object into a plain numeric/logical vector will not work.
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, which is a default behaviour of R since R does not allow }