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

Matthew Pettis matthew.pettis at gmail.com
Wed Sep 24 04:11:57 CEST 2008


Thanks Rolf,

I'm running this on Ubuntu Hardy Heron, and as far as I can tell from
http://packages.ubuntu.com/search?keywords=r-base&searchon=names&suite=hardy&section=all
, v2.6.2 is the version they have available.  The painless upgrade for
me is to use 'aptitude' to get v2.7.x, otherwise I have to build it
from scratch...

Unless you know of a repository of binaries that has v2.7.x?

Thanks,
Matt

On Tue, Sep 23, 2008 at 9:08 PM, Rolf Turner <r.turner at auckland.ac.nz> wrote:
>
> 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 confidential. If you are
> not the intended recipient please delete the message and notify the sender.
> Any views or opinions presented are solely those of the author.
>
> This e-mail has been scanned and cleared by MailMarshal
> www.marshalsoftware.com
> ######################################################################
>



-- 
It is from the wellspring of our despair and the places that we are
broken that we come to repair the world.
-- Murray Waas



More information about the R-help mailing list