Skip to content

Commit

Permalink
Merge branch 'f-#109-generic'. Fixes #109.
Browse files Browse the repository at this point in the history
- `as_data_frame()` is S3 generic again (#109).
  • Loading branch information
Kirill Müller committed Jul 1, 2016
2 parents c208fba + 17ef5ac commit bd395db
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ S3method("[[",tbl_df)
S3method("row.names<-",tbl_df)
S3method(all.equal,tbl_df)
S3method(as.data.frame,tbl_df)
S3method(as_data_frame,"NULL")
S3method(as_data_frame,data.frame)
S3method(as_data_frame,default)
S3method(as_data_frame,list)
S3method(as_data_frame,matrix)
S3method(as_data_frame,table)
S3method(as_data_frame,tbl_df)
S3method(as_tibble,"NULL")
S3method(as_tibble,data.frame)
S3method(as_tibble,default)
Expand Down
24 changes: 23 additions & 1 deletion R/dataframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,30 @@ as_tibble.default <- function(x, ...) {

#' @export
#' @rdname as_tibble
as_data_frame <- as_tibble
as_data_frame <- function(x, ...) {
UseMethod("as_data_frame")
}

#' @export
as_data_frame.tbl_df <- as_tibble.tbl_df

#' @export
as_data_frame.data.frame <- as_tibble.data.frame

#' @export
as_data_frame.list <- as_tibble.list

#' @export
as_data_frame.matrix <- as_tibble.matrix

#' @export
as_data_frame.table <- as_tibble.table

#' @export
as_data_frame.NULL <- as_tibble.NULL

#' @export
as_data_frame.default <- as_tibble.default

#' Test if the object is a tibble.
#'
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-data_frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ test_that("Can convert named atomic vectors to data frame", {


test_that("as_tibble alias", {
expect_identical(as_data_frame, as_tibble)
expect_identical(as_data_frame(NULL), as_tibble(NULL))
})


Expand Down

0 comments on commit bd395db

Please sign in to comment.