#R #min_max1
r_min <- function(x) {
out <- x[[1]]
for (i in x[-1]) {
if (i < out) {
out <- i
}
}
out
}
r_max <- function(x) {
out <- x[[1]]
for (i in x[-1]) {
if (i > out) {
out <- i
}
}
out
}
r_vector <- 1:20
r_vector
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
r_min(r_vector)
#> 1
r_max(r_vector)
#> 20