Skip to content

Commit

Permalink
explicit format.tbl_df() method, closes #263
Browse files Browse the repository at this point in the history
- The `format.tbl_df()` method is identical to `format.tbl()`, instead of calling `NextMethod()`, to protect against malformed tibbles that inherit from `"tbl_df"` but not `"tbl"`, as created e.g. by `ungroup()` in dplyr 0.5.0 and earlier (#263).
  • Loading branch information
krlmlr committed May 27, 2017
1 parent 41f9b21 commit 393bd83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -28,6 +28,7 @@ S3method(check_names_df,default)
S3method(check_names_df,logical)
S3method(check_names_df,numeric)
S3method(format,tbl)
S3method(format,tbl_df)
S3method(format,trunc_mat)
S3method(format_v,character)
S3method(format_v,default)
Expand Down
4 changes: 4 additions & 0 deletions R/tbl-df.r
Expand Up @@ -14,6 +14,10 @@ format.tbl <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) {
format(trunc_mat(x, n = n, width = width, n_extra = n_extra))
}

#' @rdname formatting
#' @export
format.tbl_df <- format.tbl

#' @rdname formatting
#' @export
print.tbl <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) {
Expand Down
3 changes: 3 additions & 0 deletions man/formatting.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 393bd83

Please sign in to comment.