tests/exporting-methods.R

# the testthat library executes test within the optmatch namespace,
# so it can't detect if we forget to export methods
# R CMD check tests, on the other hand, use the package externally

library(optmatch)

data(nuclearplants)

### as.matrix

# sparse
tmp <- match_on(pr ~ date + cost, data = nuclearplants, within = exactMatch(pr ~ pt, data = nuclearplants))

tmp.m <- as.matrix(tmp)

stopifnot(dim(tmp.m) == c(10,22))
stopifnot(class(tmp.m)[1] == "matrix")

# dense
tmp <- match_on(pr ~ date + cost, data = nuclearplants)

tmp.m <- as.matrix(tmp)

stopifnot(dim(tmp.m) == c(10,22))
stopifnot(class(tmp.m)[1] == "matrix")

Try the optmatch package in your browser

Any scripts or data that you put into this service are public.

optmatch documentation built on Nov. 16, 2023, 5:06 p.m.