Skip to contents

getmax generates upper bound for a plot where it is unknown whether the maximum is greater than zero of not. If > 0 then multiplying by the default mult of 1.05 works well but if the outcome if < 0 then the multiplier needs to be adjusted appropriately so the maximum is slightly higher than the maximum of the data

Usage

getmax(x, mult = 1.05)

Arguments

x

the vector of data to be tested for its maximum

mult

the multiplier for both ends, defaults to 1.05 (=0.95 if < 0)

Value

a suitable upper bound for a plot if required

Examples

 vect <- rnorm(10,mean=0,sd=2)
 sort(vect,decreasing=TRUE)
#>  [1]  4.3543545  1.1216139  0.7356057  0.5861252  0.2987379 -0.4890780
#>  [7] -0.5739257 -0.5817589 -1.2957193 -1.4422524
 getmax(vect,mult=1.0)
#> [1] 4.354354
 vect <- rnorm(10,mean = -5,sd = 1.5)
 sort(vect,decreasing=TRUE)
#>  [1] -3.044533 -3.184234 -3.414096 -5.094808 -5.564409 -5.987468 -6.306802
#>  [8] -7.515154 -7.927903 -8.210663
 getmax(vect,mult=1.0)
#> [1] -3.044533