verify | R Documentation |
Verifies the content of FLR objects according to a set of rules
verify(object, ...)
## S4 method for signature 'FLComp'
verify(object, ..., report = TRUE)
## S4 method for signature 'FLStock'
verify(object, rules = ruleset(object), ..., report = TRUE)
object |
An object of any FLR class for which the method has been defined |
... |
Additional rules to be tested, as a formula or list. See details |
report |
Should the standard data.frame report be output (if TRUE) or a single logical value for all tests? |
rules |
Basic set of rules for a given class, as returned by ruleset(). |
Classes' validity functions generally check the structure and dimensions of objects and their component slots. But some checks on the data content of objects is often required. The various verify methods implement both a system to create rules that an object is expected to pass, and a minimum standard set of rules for each defined class
The data.frame output by the method when report=TRUE
contains one row per
rule and the following columns:
name, the rule name
items, number of comparisons carried out
passes, number of TRUE values
fails, number of FALSE values
NAs, number of logical NAs
valid, are all values TRUE?
rule, the expression being evaluated
Additional rules can be specify in a call to verify, in one of two forms.
Simple rules can be defined as a formula involving methods defined for the
class. A rule such as highm = ~ m < 2
will check if values in the m slot are
higher than 2 and return a logical FLQuant.
Some rules cannot simply use existing methods or functions, for example those operating on all slots of the object, or requiring additional computations. In this case, the argument to verify can be a list, with an element named rule of class formula and where test is defined. The test then calls for a new function, defined as another element of the list, and which will be used by verify when evaluating the set of rules. See below for examples.
A set of rules has been defined for the FLStock class, available by calling the ruleset method. The verify method for FLStock will by default evaluate those rules, as well as any other defined in the call.
A data.frame with the results of applying those rules, or a single logical value, if report=FALSE
The FLR Team
ruleset
# Verifying a new rule for an FLSR object
data(nsher)
# rule: are all recruitment values greater than 0?
verify(nsher, rec=~rec > 0)
# Define rule calling its own function
data(ple4)
# rule: ssb is less
verify(ple4, ssbstock = ~ssb < stock)
data(ple4)
# verify for the standard set of rules for FLStock
verify(ple4)
# verify a single rule from set
verify(ple4, rules=ruleset(ple4, 'anyna'), report=FALSE)
# add own rule to set
verify(ple4, m = ~m >=0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.