Re: expand.grid() (PR#301)

About this list Date view Thread view Subject view Author view Other groups

Subject: Re: expand.grid() (PR#301)
maechler@stat.math.ethz.ch
Date: Sat 30 Oct 1999 - 00:45:34 EST


Message-Id: <199910291445.QAA13256@pubhealth.ku.dk>

>>>>> "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,

      expand.grid(NULL)

gives NULL without your change
but gives an error with your change...
since
        data.frame(NULL)
fails.

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 ?)

Martin

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:09 EST