valid | R Documentation |
valid()
is a generic intended to validate objects from a class
within the constructor function for that class. Typical usage should be of
the form:
constructor <- function (x, ...) { out <- structure(x, class = 'className') valid(out) out }
valid(x, ...)
x |
An object of the class to be validated. |
valid
is a generic function with no default. For it to work you
need to write a method for the class, usually as part of the class
definition. The valid.className
method should return TRUE
if all
conditions are met, and halt with informative error messages otherwise:
valid.className <- fuction (x) { conditions <- with(x, c( given == expected, . . . ) ) if(all(conditions)) return(TRUE) stop('Informative error message') }
TRUE
if successful.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.