Skip to content

Commit

Permalink
use documented method for resetting row names
Browse files Browse the repository at this point in the history
- also add new test
  • Loading branch information
Kirill Müller committed Mar 17, 2016
1 parent 4f934ef commit ff74592
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/rownames.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ has_rownames <- function(df) {
#' rownames(remove_rownames(mtcars))
remove_rownames <- function(df) {
stopifnot(is.data.frame(df))
attr(df, "row.names") <- .set_row_names(nrow(df))
rownames(df) <- NULL
df
}

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-rownames.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ test_that("has_rownames and remove_rownames", {
expect_false(has_rownames(iris))
expect_true(has_rownames(mtcars))
expect_false(has_rownames(remove_rownames(mtcars)))
expect_false(has_rownames(remove_rownames(iris)))
expect_error(has_rownames(1:10))
})

Expand Down

0 comments on commit ff74592

Please sign in to comment.