Paul E. Johnson wrote:> I handed out some results from glm() and the students ask "how many > observations were dropped due to missing values"? > > How would I know? > > In other stat programs, the results will typically include N and > the number dropped because of missings. Without going back to R and > fiddling about to find the total number of rows in the dataframe, > there is no way to tell. Somewhat inconvenient. Do you agree?In a word: No. R is ``not like other packages'' which spew out enormous printouts including every statistic known to man and a few known only to woman. R basically gives you what you ask for, and assumes you know enough to know what to ask for. It does not condescendingly make decisions for you and hand-cuff you into doing a standard analysis. It also allows infinitely versatile customization with consumate ease since it is a beautifully designed programming language. It would be ***VERY*** easy to write a wrapper for glm() to include the number of dropped observations if you want to include that information in a ``printout''. cheers, Rolf Turner rolf at math.unb.ca
Rolf Turner wrote:> Paul E. Johnson wrote: > > >>I handed out some results from glm() and the students ask "how many >>observations were dropped due to missing values"? >> >>How would I know?...> It > would be ***VERY*** easy to write a wrapper for glm() to include > the number of dropped observations if you want to include that > information in a ``printout''.To wit naPrint <- function(model,...) { if(!inherits(model,"lm") || !inherits(model,"glm")) stop("no support for class ",class(model),"\n") if(!is.null(model$na.action)) { action <- paste("na.action:",attr(model$na.action,"class")) rows <- as.numeric(model$na.action) list(action=action,rows=rows) } else { #no missing values list(action=options()$na.action, rows=NULL) } } Building this as a generic function and its methods is left as an exercise ;) So is a a prettier print method, and possibly a method for latex() or xtable(). Cheers Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz 64-21-343-545 jasont at indigoindustrial.co.nz
Whoops. That should be a "&&" where I put a "||". naPrint <- function(model,...) { if(!inherits(model,"lm") && !inherits(model,"glm")) stop("no support for class ",class(model),"\n") if(!is.null(model$na.action)) { action <- paste("na.action:",attr(model$na.action,"class")) rows <- as.numeric(model$na.action) list(action=action,rows=rows) } else { #no missing values list(action=options()$na.action, rows=NULL) } } -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz 64-21-343-545 jasont at indigoindustrial.co.nz