compare {dMod} | R Documentation |
Compare two objects and return differences
Description
Works eigher on a list or on two arguments. In case of a list, comparison is done with respect to a reference entry. Besides the objects themselves also some of their attributes are compared, i.e. "equations", "parameters" and "events" and "forcings".
Usage
compare(vec1, ...)
## S3 method for class 'list'
compare(vec1, vec2 = NULL, reference = 1, ...)
## S3 method for class 'character'
compare(vec1, vec2 = NULL, ...)
## S3 method for class 'eqnvec'
compare(vec1, vec2 = NULL, ...)
## S3 method for class 'data.frame'
compare(vec1, vec2 = NULL, ...)
Arguments
vec1 |
object of class eqnvec, |
... |
arguments going to the corresponding methods |
vec2 |
same as vec1. Not used if vec1 is a list. |
reference |
numeric of length one, the reference entry. |
Value
data.frame
or list of data.frames with the differences.
Examples
## Compare equation vectors
eq1 <- eqnvec(a = "-k1*a + k2*b", b = "k2*a - k2*b")
eq2 <- eqnvec(a = "-k1*a", b = "k2*a - k2*b", c = "k2*b")
compare(eq1, eq2)
## Compare character vectors
c1 <- c("a", "b")
c2 <- c("b", "c")
compare(c1, c2)
## Compare data.frames
d1 <- data.frame(var = "a", time = 1, value = 1:3, method = "replace")
d2 <- data.frame(var = "a", time = 1, value = 2:4, method = "replace")
compare(d1, d2)
## Compare structures like prediction functions
fn1 <- function(x) x^2
attr(fn1, "equations") <- eq1
attr(fn1, "parameters") <- c1
attr(fn1, "events") <- d1
fn2 <- function(x) x^3
attr(fn2, "equations") <- eq2
attr(fn2, "parameters") <- c2
attr(fn2, "events") <- d2
mylist <- list(f1 = fn1, f2 = fn2)
compare(mylist)
[Package dMod version 1.0.2 Index]