I am using the rpart package and seem to have trouble with data sets that have columns with no data. I look at the column data in R and all values are NA. When this occurs, I get nothing back from the rpart function. Is there a way to get the rpart package to ignore these columns, without knowing what columns are empty? I have tried the na.action=na.omit and na.action=na.exclude, but neither one fixes the problem. Thanks, Don -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 29 Apr 2002, dstierman wrote:> I am using the rpart package and seem to have trouble with data sets that > have columns with no data. I look at the column data in R and all values are > NA. When this occurs, I get nothing back from the rpart function. Is there a > way to get the rpart package to ignore these columns, without knowing what > columns are empty?That's what happens by default! data(kyphosis) kyphosis$dummy <- as.numeric(rep(NA, 81)) rpart(Kyphosis ~ ., data=kyphosis) has a column with all NAs and works correctly, so I don't think your hypothesis is the correct one.> I have tried the na.action=na.omit and > na.action=na.exclude, but neither one fixes the problem.Both na.omit and na.exclude all the rows if each contains an NA! Why are you putting a column that is entirely NAs (and that's not empty, BTW) in your formula? It is easy to find and omit empty columns if you want to: kyphosis[sapply(kyphosis, function(x) !all(is.na(x)))] -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> I am using the rpart package and seem to have trouble with data setsthat> have columns with no data. I look at the column data in R and allvalues are> NA. When this occurs, I get nothing back from the rpart function. Isthere a> way to get the rpart package to ignore these columns, without knowingwhat> columns are empty? I have tried the na.action=na.omit and > na.action=na.exclude, but neither one fixes the problem. > Thanks, DonEither fill out the formula in the first argument to rpart() to exclude those variables, or create a new data.frame without them. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._