25.3 Vector functions

df <- tibble(
  a = rnorm(5),
  b = rnorm(5),
  c = rnorm(5),
  d = rnorm(5),
)

df |> mutate(
  a = (a - min(a, na.rm = TRUE)) / 
    (max(a, na.rm = TRUE) - min(a, na.rm = TRUE)),
  b = (b - min(b, na.rm = TRUE)) / 
    (max(b, na.rm = TRUE) - min(a, na.rm = TRUE)),
  c = (c - min(c, na.rm = TRUE)) / 
    (max(c, na.rm = TRUE) - min(c, na.rm = TRUE)),
  d = (d - min(d, na.rm = TRUE)) / 
    (max(d, na.rm = TRUE) - min(d, na.rm = TRUE)),
)
## # A tibble: 5 × 4
##       a     b     c     d
##   <dbl> <dbl> <dbl> <dbl>
## 1 1     0     0.806 0.738
## 2 0.741 1.19  0.716 1    
## 3 0     1.85  0.626 0.781
## 4 0.300 1.00  1     0    
## 5 0.700 0.266 0     0.395
# Can you spot out the error in the above code?