expand.grid() (PR#301)

maechler@stat.math.ethz.ch maechler@stat.math.ethz.ch
Fri, 29 Oct 1999 16:45:34 +0200 (MET DST)

>>>>> "JonR" == J C Rougier <J.C.Rougier@durham.ac.uk> writes:

    JonR> This is a very minor point and I hesitate to call it a bug, but
    JonR> might I suggest modifying the nargs=1 return statement in
    JonR> expand.grid() from

    JonR>     if (nargs == 1) return(args[[1]])

    JonR> to

    JonR>     if (nargs == 1) return(data.frame(args))

    JonR> so that the result of expand.grid is always a data frame (as
    JonR> indicated in the help file).  This also preserves the variable
    JonR> name if it exists.

Well, that is not quite true,


gives NULL  without your change 
but gives an error with your change...

The following (only this one of all 4 possibilities  as/no-as  x NULL/list() )
would work

> as.data.frame(list())
NULL data frame with 0 rows

Better patch ? (and what does S do ?)


r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch