withinIntegerRange: Get integer within a range

Description Usage Arguments Value Examples

View source: R/withinIntegerRange.R

Description

Assures that what is returned is an integer within the specified range. Real values are truncated. Non-numerics are forced to minimum without warning.

Usage

1
withinIntegerRange(int = 0, minimum = 0, maximum = 0, na = "min")

Arguments

int

value to be forced within a range

minimum

minimum integer value.

maximum

maximum integer value

na

if "min" then non-numerics are forced to the minimum in the range If "max" then non-numerics are forced to the maximum in the range. If not either "min" or "max" it is forced to "min".

Value

A vector of integers forced to be within the specified range.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(nprcgenekeepr)
withinIntegerRange()
withinIntegerRange( , 0, 10)
withinIntegerRange(NA, 0, 10, na = "max")
withinIntegerRange( , 0, 10, na = "max") # no argument is not NA
withinIntegerRange(LETTERS, 0, 10)
withinIntegerRange(2.6, 1, 5)
withinIntegerRange(2.6, 0, 2)
withinIntegerRange(c(0, 2.6, -1), 0, 2)
withinIntegerRange(c(0, 2.6, -1, NA), 0, 2)
withinIntegerRange(c(0, 2.6, -1, NA), 0, 2, na = "max")
withinIntegerRange(c(0, 2.6, -1, NA), 0, 2, na = "min")

rmsharp/nprcmanager documentation built on April 24, 2021, 3:13 p.m.