na.exclude
,
na.omit
),
causes an error if missing values are encountered (
na.fail
),
or returns the object unchanged (
na.pass
).
na.exclude(object, ...) na.omit(object, ...) na.fail(object, ...) na.pass(object)
bdFrame
.
bdFrame
,
consisting of the rows of
object
for which
none of the variables had any missing values.
Variables that act like matrices
(that is, that have a dimension attribute of length 2)
will be examined column-by-column.
All other variables will be treated as vectors or
bdVector
s.
Variables of non-atomic mode are ignored.
na.fail
causes an error if missing values are present.
These functions may be given to model fitting functions such as
lm
via their
na.action
argument.
The
na.omit
and
na.exclude
functions return the same
data frame or
bdFrame
.
However,
na.exclude
adds
extra information on which rows were removed as the
na.action
attribute of the data frame or
bdFrame
.
This information may be used by functions such as
fitted
,
resid
,
and
predict
to pad their
results with NAs in parallel with the omitted rows.
See help on
naresid
for details.
Historically,
na.omit
was the recommended (and only) method
for omitting rows with missing values through the
na.action
argument.
Because of the extra functionality provided by the
na.exclude
function it is now the recommended
na.action
.
## Using na.exclude Tm <- na.exclude(claims) unclass(attr(Tm, "na.action")) dim(Tm) # [1] 123 5 dim(claims) # [1] 128 5 ## How to find which rows were excluded used <- match(row.names(claims), row.names(Tm)) omitted <- seq(nrow(claims))[is.na(used)] omitted # [1] 12 15 16 32 80 ## Setting na.action, compare results lm(cost ~ age + type + car.age, data = claims, weights = number, na.action = na.exclude) lm(cost ~ age + type + car.age, data = claims, weights = number, na.action = na.pass)