Hello I have a data frame with 20 columns but here is a reproducible copy:
test_df <- data.frame(a = sample(1:20,7), b = sample(1:50,7), c= sample(1:29,7) )
max_values <- c(20,50,29)
I want to normalize each column with the corresponding index of its "max_values", please do not assume each column's max value is going to be equal to the max value I want that column to be normalized as. It is okay if it goes above 1 and below zero. The max values are the thresholds and I would like the observe how the data I have goes beyond or below it. We can assume that the min values are ALWAYS going to be 0, so I took them away from the equation:
normalize <- function(x,y) {
return ((x - 0) / (y - 0))
}
lapply(test_df, normalize)
I have written the code above, but I do not know how to set it so that each iteration corresponds to a different index of "max_values"