magRange Magnify the range of a variable.
magRange.RdBy default, R's range function returns the minimum and maximum values of a variable. This returns a magnified range. It is used for some plotting functions in the rockchalk package
Arguments
- x
an R vector variable
- mult
a multiplier by which to magnify the range of the variable. A value of 1 leaves the range unchanged. May be a scalar, in which case both ends of the range are magnified by the same amount. May also be a two valued vector, such as c(minMag, maxMag), in which case the magnification applied to the minimum is minMag and the magnification of the maximum is maxMag. After version 1.5.5, mult may be smaller than 1, thus shrinking the range. Setting mult to values closer to 0 causes the range to shrink to the center point from both sides.
Examples
x1 <- c(0, 0.5, 1.0)
range(x1)
#> [1] 0 1
magRange(x1, 1.1)
#> [1] -0.1 1.1
magRange(x1, c(1.1, 1.4))
#> [1] -0.1 1.4
magRange(x1, 0.5)
#> [1] 0.25 0.75
magRange(x1, c(0.1, 0.1))
#> [1] 0.45 0.55
x1 <- rnorm(100)
range(x1)
#> [1] -2.274719 2.192465
magRange(x1)
#> [1] -3.391515 3.309261
magRange(x1, 1.5)
#> [1] -4.508311 4.426057
magRange(x1, c(1,1.5))
#> [1] -2.274719 4.426057