I am trying to execute the code from here:
Change the class from factor to numeric of many columns in a data frame
in a dataframe with 140 columns
cols = c(1:140);
merged_dataset[,cols] = apply(merged_dataset[,cols], 2, function(x) as.numeric(as.character(x)));
the problem is for some columns I get NAs. Is there a way somehow exclude these columns from the code so that I keep the data and they don't get transformed into NAs? I see the type of these columns is character if that helps.