Matthew Pettis
2008-Sep-24 01:49 UTC
[R] print.data.frame : row.name = FALSE not having intended effect
Hi, Does anybody know if row.name = FALSE actually works in v2.6.2? Because it isn't working for me... here is some sample code and output: ====+====+====+====+====+====+====+====+====+====+> print(x,row.names = FALSE)party_abbr candidate_name votes_candidate 2 DFL AMY KLOBUCHAR 1,278,849 5 R MARK KENNEDY 835,653 4 IP ROBERT FITZGERALD 71,194 3 GP MICHAEL JAMES CAVLAN 10,714 1 CP BEN POWERS 5,408 10 WI WRITE-IN** 901 8 WI PETER IDUSOGIE** 29 6 WI CHARLES ALDRICH** 15 9 WI REBECCA WILLIAMSON** 5 7 WI JOHN ULDRICH** 4>====+====+====+====+====+====+====+====+====+====+ Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas
Matthew Pettis
2008-Sep-24 01:55 UTC
[R] print.data.frame : row.name = FALSE not having intended effect
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? Thanks, Matt On Tue, Sep 23, 2008 at 8:49 PM, Matthew Pettis <matthew.pettis at gmail.com> wrote:> Hi, > > Does anybody know if row.name = FALSE actually works in v2.6.2? > Because it isn't working for me... here is some sample code and > output: > > ====+====+====+====+====+====+====+====+====+====+ >> print(x,row.names = FALSE) > party_abbr candidate_name votes_candidate > 2 DFL AMY KLOBUCHAR 1,278,849 > 5 R MARK KENNEDY 835,653 > 4 IP ROBERT FITZGERALD 71,194 > 3 GP MICHAEL JAMES CAVLAN 10,714 > 1 CP BEN POWERS 5,408 > 10 WI WRITE-IN** 901 > 8 WI PETER IDUSOGIE** 29 > 6 WI CHARLES ALDRICH** 15 > 9 WI REBECCA WILLIAMSON** 5 > 7 WI JOHN ULDRICH** 4 >> > ====+====+====+====+====+====+====+====+====+====+ > > Thanks, > Matt > > -- > It is from the wellspring of our despair and the places that we are > broken that we come to repair the world. > -- Murray Waas >-- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas
Steven McKinney
2008-Sep-24 02:07 UTC
[R] print.data.frame : row.name = FALSE not having intendedeffect
Here's the current method for printing a data frame:> print.data.framefunction (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) } <environment: namespace:base>>so you can either set up your own copy of this or make a matrix copy of your data frame (as done in the function above) and set the row names to "" HTH Steve McKinney -----Original Message----- From: r-help-bounces at r-project.org on behalf of Matthew Pettis Sent: Tue 9/23/2008 6:55 PM To: r-help at r-project.org Subject: Re: [R] print.data.frame : row.name = FALSE not having intendedeffect 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? Thanks, Matt On Tue, Sep 23, 2008 at 8:49 PM, Matthew Pettis <matthew.pettis at gmail.com> wrote:> Hi, > > Does anybody know if row.name = FALSE actually works in v2.6.2? > Because it isn't working for me... here is some sample code and > output: > > ====+====+====+====+====+====+====+====+====+====+ >> print(x,row.names = FALSE) > party_abbr candidate_name votes_candidate > 2 DFL AMY KLOBUCHAR 1,278,849 > 5 R MARK KENNEDY 835,653 > 4 IP ROBERT FITZGERALD 71,194 > 3 GP MICHAEL JAMES CAVLAN 10,714 > 1 CP BEN POWERS 5,408 > 10 WI WRITE-IN** 901 > 8 WI PETER IDUSOGIE** 29 > 6 WI CHARLES ALDRICH** 15 > 9 WI REBECCA WILLIAMSON** 5 > 7 WI JOHN ULDRICH** 4 >> > ====+====+====+====+====+====+====+====+====+====+ > > Thanks, > Matt > > -- > It is from the wellspring of our despair and the places that we are > broken that we come to repair the world. > -- Murray Waas >-- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas ______________________________________________ R-help at 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.