check.num.args: Numeric argument validator

Description Usage Arguments Author(s) Examples

View source: R/metaseqr.argcheck.R

Description

Checks if one or more given numeric argument(s) satisfy several rules concerning numeric arguments, e.g. proper bounds or proper format (e.g. it must be a number and not a character). Mostly for internal use.

Usage

1
2
    check.num.args(arg.name, arg.value, arg.type, arg.bounds,
        direction)

Arguments

arg.name

the name of the argument that is checked (for display purposes).

arg.value

the value(s) of the argument to be checked.

arg.type

either the string "numeric" to denote generic double-like R numerics or "integer" for integer values.

arg.bounds

a numeric or a vector with 2 elements, restraining arg.value to be within the bounds defined by the input vector or e.g. larger (smaller) than the numeric value. See examples.

direction

a string denoting to which direction the arg.value should be compared with arg.bounds. For example, "both" should be given with a two element vector against which, arg.value will be checked to see whether it is smaller than the low boundary or larger than the higher boundary. In that case, the function will throw an error. The direction parameter can be one of: "both" (described above), "botheq" (as above, but the arg.val is also checked for equality -closed intervals), "gt" or "gte" (check whether arg.val is smaller or smaller than or equal to the first value of arg.bounds), "lt" or "lte" (check whether arg.val is larger or larger than or equal to the first value of arg.bounds).

Author(s)

Panagiotis Moulos

Examples

1
2
3
4
5
6
7
8
pcut <- 1.2 # A probability cannot be larger than 1! It will throw an error!
#check.num.args("pcut",pcut,"numeric",c(0,1),"botheq")
pcut <- 0.05 # Pass
check.num.args("pcut",pcut,"numeric",c(0,1),"botheq")
gc.col <- 3.4 # A column in a file cannot be real! It will throw an error!
#check.num.args("gc.col",gc.col,"integer",0,"gt")
gc.col <- 5L # Pass
check.num.args("gc.col",gc.col,"integer",0,"gt")

pmoulos/metaseqr documentation built on Dec. 29, 2020, 5:56 a.m.