[R] print.data.frame : row.name = FALSE not having intended effect

Rolf Turner r.turner at auckland.ac.nz
Wed Sep 24 04:08:45 CEST 2008


On 24/09/2008, at 1:55 PM, Matthew Pettis wrote:

> Never mind -- the answer is buried in my own question... I was looking
> at documentation for version 2.7.2, and when I looked at the one for
> 2.6.2, I see the row.names option isn't in that release.
>
> Any suggestions on how I can code around that in 2.6.2, so I don't
> have to upgrade to 2.7.2 just yet?

Why not just upgrade?  It's painless, and should be done anyhow.

Be that as it may, here's the code for print.data.frame from R 2.7.2:

function (x, ..., digits = NULL, quote = FALSE, right = TRUE,
     row.names = TRUE)
{
     n <- length(row.names(x))
     if (length(x) == 0L) {
         cat("NULL data frame with", n, "rows\n")
     }
     else if (n == 0L) {
         print.default(names(x), quote = FALSE)
         cat("<0 rows> (or 0-length row.names)\n")
     }
     else {
         m <- as.matrix(format.data.frame(x, digits = digits,
             na.encode = FALSE))
         if (!isTRUE(row.names))
             dimnames(m)[[1]] <- if (identical(row.names, FALSE))
                 rep.int("", n)
             else row.names
         print(m, ..., quote = quote, right = right)
     }
     invisible(x)
}

	cheers,

		Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list