Apply a ceiling and floor to all values in a matrix
MinMax(data, min, max)
Matrix or data frame
all values below this min value will be replaced with min
all values above this max value will be replaced with max
Returns matrix after performing these floor and ceil operations
mat <- matrix(data = rbinom(n = 25, size = 20, prob = 0.2 ), nrow = 5)
mat
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 3 6 3 4 5
#> [2,] 4 5 6 5 4
#> [3,] 4 5 5 1 6
#> [4,] 4 2 5 4 4
#> [5,] 2 5 4 5 3
MinMax(data = mat, min = 4, max = 5)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 4 5 4 4 5
#> [2,] 4 5 5 5 4
#> [3,] 4 5 5 4 5
#> [4,] 4 4 5 4 4
#> [5,] 4 5 4 5 4