NA
to any discrete predictor in a data frame
that contains
NA
s.
na.tree.replace
stops if any continuous (numeric) predictor
contains an
NA
.
na.tree.replace.all
will quantize numeric predictors and
create a factor with a level for the missing values.
na.tree.replace(frame) na.tree.replace.all(frame)
"NA"
is added to any discrete predictor in
frame
with
NA
s.
In the case of
na.tree.replace.all
,
all predictors having
NA
s are changed
in an analogous manner.
This function is used via the
na.action
argument
to
tree
.
The use of
na.tree.replace.all
for continuous
variables with missing values might be risky.
These continuous predictors are replaced by factors based on their quartiles.
This migh be a good exploratory step but it raises a problem
if used in predictions.
If the variable has missing values in only one of the fitted
or the new datasets,
the values used may turn out completely incompatible (factor vs. numeric).
z <- tree(market.survey, na.action=na.tree.replace)