Error in colMeans(x, na.rm = TRUE) : ‘x’ must be numeric, What should I do in this situation?

As Roland pointed out, you can not scale categorical variables… In your case subsetting the data.frame to the columns with numeric values would help.

beach_z <- as.data.frame(apply(beach[c('SPEOPLE','SCAR')], scale))
# or maybe easier...
beach_z <- scale(beach[c('SPEOPLE','SCAR')])

Leave a Comment