I have a dataframe with a combination of numeric, and factor variables.
I am trying to recursively replace all outliers (3 x SD) with NA however I'm having problems with the following error
Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric
The code i was using is
name = factor(c("A","B","NA","D","E","NA","G","H","H"))
height = c(120,NA,150,170,NA,146,132,210,NA)
age = c(10,20,0,30,40,50,60,NA,130)
mark = c(100,0.5,100,50,90,100,NA,50,210)
data = data.frame(name=name,mark=mark,age=age,height=height)
data
data[is.na(data)] <- 77777
data.scale <- scale(data)
data.scale[ abs(data.scale) > 3 ] <- NA
data <- data.scale
Any suggestions on how to get this working?