Hello,
In order for us to help you, we'll need a minimal reproducible example where we can see the data or at least some dummy data where the H and NH are present.
Please look at this post for creating such example:
Also, I see that you are repeating a lot of code for normalizing columns in a data frame. Here is a way to write it more efficiently:
library("dplyr")
#Create fake data
myData = data.frame(x = sample(1:50, 10),
y = sample(letters, 10),
z = sample(1:50, 10))
#Create normalize function
normalize <- function(data){
(data - min(data))/(max(data) - min(data))
}
#Apply normalize function to all columns of interest at once
#Tidyverse implementation ...
myData = myData %>% mutate_at(c("x", "z"), normalize)
# ... or standard R implementation
myData[,c("x", "z")] = apply(myData[,c("x", "z")], 2, normalize)
Good luck,
PJ