| 6.2.common.check.functions | R Documentation | 
Various pems.utils workhorse functions for input checking and routine data handling.
checkOption(option=NULL, allowed.options=NULL,
           option.name = "option", allowed.options.name = "allowed.options",
           partial.match=TRUE, fun.name = "checkOption", 
           if.missing = c("stop", "warning", "return"),
           output = c("option", "test.result"), ...)
checkPEMS(data = NULL, fun.name = "checkPEMS",
           if.missing = c("return", "warning", "stop"),
           output = c("pems", "data.frame", "test.result"),
           ...) 
checkUnits(input = NULL, units = NULL, data = NULL, 
           input.name = NULL, fun.name = "checkUnits", 
           if.missing = c("stop", "warning", "return"),
           output = c("special", "units", "input", "test.result"),
           ..., unit.conversions = NULL)
checkOutput(input = NULL, data = NULL,
           input.name = NULL, fun.name = "checkOutput", 
           if.missing = c("stop", "warning", "return"),
           output = c("pems", "data.frame", "input", "test.result"),
           overwrite = FALSE, ...)
checkIfMissing(..., if.missing = c("stop", "warning", "return"), 
           reply = NULL, suggest = NULL, if.warning = NULL, 
           fun.name = NULL)
| input | (vector, object or object element) An input to be tested or recovered for 
subsequent use by another function, e.g. a speed measurement from a  | 
| data | (data.frame, pems object) If supplied, the assumed source for an  | 
| input.name,option.name | (Optional character vectors) If a  | 
| fun.name | (Optional character vector) If a  | 
| if.missing | (Optional character vector) How to handle an input, option, etc, if missing, not supplied or  | 
| output | (Character vector) Output mode for  | 
| ... | (Optional) Other arguments, currently ignored by all  | 
| option,allowed.options,allowed.options.name | (Character vectors) For  | 
| partial.match | (Logical) For  | 
| units | (Character vector) For  | 
| unit.conversions | (List) For  | 
| overwrite | (Logical) For  | 
| reply,suggest,if.warning | (Character vectors) For  | 
The check... functions are intended as a means of future-proofing pems.utils data 
handling. They provide routine error/warning messaging and consistent 'front-of-house' handling 
of function arguments regardless of any underlying changes in the structure of the pems 
objects and/or pems.utils code. This means third-party function developed using these 
functions should be highly stable.
checkOption checks a supplied option against a set of allowed options, and then if present or 
matchable returns the assigned option. It is intended as a workhorse for handling optional function 
arguments.  
checkPEMS checks a supplied data source and provides a short-cut for converting this 
to and from data.frames and pems object classes. It is intended as a 'best-of-both-worlds' 
mechanism, so users can supply data in various different formats, but function developers only 
have to work with that data in one (known) format. 
checkUnits checks the units of a previously recovered input, and then, depending on the 
output setting, returns either the units of the input or the input in the 
required units (assuming the associated conversion is known).
checkOutput packs/repacks a previously recovered input. Depending on the output setting, this 
can be as the (standalone) input, an element of a data.frame or an element of a pems object.  
checkIfMissing if a workhorse function for the if.missing argument. If any of the supplied 
additional arguments are NULL, it stops, warns and continues or continues a parent function according to 
the if.missing argument. If supplied, reply, suggest and if.warning arguments are 
used to generate the associated error or warning message.
All check... functions return a logical if output = "test.result", TRUE 
if the input, option, etc., is suitable for use in that fashion or FALSE if not.      
Otherwise,
checkOption return the option argument if valid (on the basis of if.missing) or an 
error, warning and/or NULL (on the basis of if.missing) if not. If partial.match = TRUE 
and partial matching is possible this is in the full form given in allowed.options regardless of 
the degree of abbreviation used by the user.
checkPEMS returns the data argument if valid or an error, warning and/or NULL (on the basis 
of if.missing) if not. Depending on output setting, the valid return is either a data.frame 
or pems object.
checkUnits returns the units of the input argument if no other information is supplied and 
units have previously been assigned to that input. If units are assigned in the call 
or output is forced (output = "input"), the input is returned in the requested 
units. If this action is not possible (e.g. pems.utils does not know the conversion), the 
function returns an error, a warning and the unchanged input or the unchanged input alone 
depending on if.missing setting.
Depening on if.missing argument, checkIfMissing either stops all parent functions with an error 
message, warns of a problem but allows parent functions to continue running, or allows parent functions to 
continue without informing the user. 
The ...name arguments allow the check... functions to be used silently. 
If a parent function is identified as fun.name and the check case (input, 
option, etc.) is identified with the associated ...name argument these are 
used in any associated error messaging.
Karl Ropkins
[TO DO]
See ref.unit.conversions and convertUnits for general unit handling. 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.