[Rd] na.action(lmObject) -> NULL instead of lmObject$na.action

William Dunlap wdunlap at tibco.com
Sat May 1 00:40:21 CEST 2010


I think the following three calls to na.action() should
return the same thing, but the last returns NULL.

  > d <- data.frame(x=c(1,2,NA,NA,5), y=log(1:5),
row.names=LETTERS[1:5])
  > na.action(na.exclude(d))
  C D
  3 4
  attr(,"class")
  [1] "exclude"
  > na.action(model.frame(y~x, data=d, na.action=na.exclude))
  C D
  3 4
  attr(,"class")
  [1] "exclude"
  > na.action(fit <- lm(y~x, data=d, na.action=na.exclude))
  NULL

lm() returns a list component called "na.action" while
na.exclude() and model.frame() return the same thing as
an attribute called "na.action".

  > fit$na.action
  C D
  3 4
  attr(,"class")
  [1] "exclude"

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 



More information about the R-devel mailing list