[R] expand.grid

Martin Maechler maechler at stat.math.ethz.ch
Wed May 14 15:39:10 CEST 2003


>>>>> "Giovanni" == Giovanni Marchetti <gmm at ds.unifi.it>
>>>>>     on Sat, 3 May 2003 23:48:48 +0000 writes:

    Giovanni> I recently posted a question concerning an
    Giovanni> inconsistency of expand.grid in defining the
    Giovanni> reference level of the factors.

    > > expand.grid(x = c("b", "a"), y = c(1, 2))$x
    > [1] b a b a
    > Levels: b a            # reference level is b
    > > expand.grid(x = c("b", "a"))$x
    > [1] b a
    > Levels: a b            # reference level is a

    Giovanni> Thank you very much for the ready explanations and
    Giovanni> comments.

    Giovanni> I found this inconsistency working with
    Giovanni> contingency tables and logistic models.

Ciao Giovanni,

I've forgotten to tell you (and the audience) that this has been
chnaged in R-patched (to be 1.7.1) where 
expand.grid(x1) and expand.grid(x1,x2) will be consistent.

Thank you for your posting!
Martin




More information about the R-help mailing list