I also not find this in the source code, but you can rewrite the function
with this:

expand.grid <-
function (..., KEEP.OUT.ATTRS = TRUE, stringsAsFactors = FALSE)
{
    nargs <- length(args <- list(...))
    if (!nargs)
        return(as.data.frame(list()))
    if (nargs == 1L && is.list(a1 <- args[[1L]]))
        nargs <- length(args <- a1)
    if (nargs == 0L)
        return(as.data.frame(list()))
    cargs <- args
    iArgs <- seq_len(nargs)
    nmc <- paste("Var", iArgs, sep = "")
    nm <- names(args)
    if (is.null(nm))
        nm <- nmc
    else if (any(ng0 <- nzchar(nm)))
        nmc[ng0] <- nm[ng0]
    names(cargs) <- nmc
    rep.fac <- 1L
    d <- sapply(args, length)
    if (KEEP.OUT.ATTRS) {
        dn <- vector("list", nargs)
        names(dn) <- nmc
    }
    orep <- prod(d)
    if (orep == 0L) {
        for (i in iArgs) cargs[[i]] <- args[[i]][FALSE]
    }
    else {
        for (i in iArgs) {
            x <- args[[i]]
            if (KEEP.OUT.ATTRS)
                dn[[i]] <- paste(nmc[i], "=", if (is.numeric(x))
                  format(x)
                else x, sep = "")
            nx <- length(x)
            orep <- orep/nx
            x <- x[rep.int(rep.int(seq_len(nx), rep.int(rep.fac,
                nx)), orep)]
        if(stringsAsFactors){
                if (!is.factor(x) && is.character(x))
                    x <- factor(x, levels = unique(x))
        }else{
            x
        }
            cargs[[i]] <- x
            rep.fac <- rep.fac * nx
        }
    }
    if (KEEP.OUT.ATTRS)
        attr(cargs, "out.attrs") <- list(dim = d, dimnames = dn)
    rn <- .set_row_names(as.integer(prod(d)))
    structure(cargs, class = "data.frame", row.names = rn)
}

On Thu, Jun 25, 2009 at 8:21 AM, Rainer M Krug <r.m.krug@gmail.com> wrote:

> Hi
>
> I have the feeling, that the argument stringsAsFactors has no impact in the
> function expand.grid:
>
> a <- c("PR", "NC", "A2", "BS")
> b <- c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125)
>
> class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]])
> [1] "factor"
> class(expand.grid(css, fscs, stringsAsFactors=TRUE)[[1]])
> [1] "factor"
>
> Also, when I look at the code of expand.grid,  stringsAsFactors does not
> occur in the code.
>
> Am I missing something?
>
> > version
>               _
> platform       i486-pc-linux-gnu
> arch           i486
> os             linux-gnu
> system         i486, linux-gnu
> status
> major          2
> minor          9.0
> year           2009
> month          04
> day            17
> svn rev        48333
> language       R
> version.string R version 2.9.0 (2009-04-17)
>
> Cheers,
>
> Rainer
> --
> Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch
> University, South Africa
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]


