I assume you are referring to na.roughfix in randomForest. I don't think it works for logical vectors or for factors outside of data frames:
> library(randomForest) > DF <- data.frame(a = c(T, F, T, NA, T), b = c(1:3, NA, 5)) > na.roughfix(DF) Error in na.roughfix.data.frame(DF) : na.roughfix only works for numeric or factor > DF$a <- factor(DF$a) > na.roughfix(DF$a) Error in na.roughfix.default(DF$a) : roughfix can only deal with numeric data. > na.roughfix(DF) a b 1 TRUE 1.0 2 FALSE 2.0 3 TRUE 3.0 4 TRUE 2.5 5 TRUE 5.0 On 3/30/07, Sergio Della Franca <[EMAIL PROTECTED]> wrote: > Dear R-Helpers, > > > I have the following data set(y): > > Test_Result #_Test > t 10 > f 14 > f 25 > f NA > f 40 > t 45 > t 44 > <NA> 47 > t NA > > > I want to replace the NA values with the following method: > - for the numeric variable, replace NA with median > - for character variable , replace NA with the most frequent level > > If i use x<-na.roughfix(y) the NA values are correctly replaced. > But if i x<-na.roughfix(y$Test_Result) i obtain the following error: > > roughfix can only deal with numeric data. > > How can i solve this proble that i met every time i want to replace only the > NA values of a column (type character)? > > Thank you in advance. > > > Sergio Della Franca > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.