Hello,

Is this a bug in codetools:

> codetools::showTree( body( glm) )
("{" (<- call (match.call)) (if (is.character family) (<- family (get family "function" (parent.frame)))) (if (is.function family) (<- family(family))) (if (is.null ($ family family)) ("{" (print family) (stop "'family' not recognized"))) (if (missing data) (<- data (environment formula))) (<- mf (match.call FALSE)) (<- m (match (c "formula" "data" "subset" "weights" "na.action" "etastart" "mustart" "offset") (names mf) 0L)) (<- mf ([ mf (c 1 m))) (<- ($ mf drop.unused.levels) TRUE) (<- ([[ mf 1L) (as.name "model.frame")) (<- mf (eval mf (parent.frame))) (switch method (return mf) 1 (stop "invalid 'method': " method)) (<- mt (attr mf "terms")) (<- Y (model.response mf "any")) (if (== (length (dim Y)) 1L) ("{" (<- nm (rownames Y)) (<- (dim Y) NULL) (if (! (is.null nm)) (<- (names Y) nm)))) (<- X (if (! (is.empty.model mt)) (model.matrix mtmf contrasts) (matrix Error in typeof(e) :
 element 1 is empty;
  the part of the args list of '.Internal' being evaluated was:
  (x)


The problem seems to happen because of the call to matrix with a missing argument in glm: matrix(, NROW(Y), 0L)

The fix is to rewrite showTreeCall like this :

showTreeCall <- function (e, w)
{
   w$write("(")
   walkCode(e[[1]], w)
   for (a in as.list(e[-1])) {
       if( !missing(a)){
               w$write(" ")
               walkCode(a, w)
       }
   }
   w$write(")")
}

> version
              _
platform       i686-pc-linux-gnu
arch           i686
os             linux-gnu
system         i686, linux-gnu
status         Under development (unstable)
major          2
minor          9.0
year           2009
month          03
day            03
svn rev        48044
language       R
version.string R version 2.9.0 Under development (unstable) (2009-03-03 r48044)

--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to