Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add as.tibble as an alias to as_tibble #160

wants to merge 2 commits into from


Copy link

@anhqle anhqle commented Aug 22, 2016

Add as.tibble as an alias to as_tibble, similar to as_data_frame. Add documentation and a short test. Resolve #124

Copy link

codecov-io commented Aug 22, 2016

Current coverage is 99.44% (diff: 100%)

Merging #160 into master will increase coverage by <.01%

@@             master       #160   diff @@
  Files            16         16          
  Lines           716        717     +1   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
+ Hits            712        713     +1   
  Misses            4          4          
  Partials          0          0          

Powered by Codecov. Last update c3f286e...384a194

@@ -229,6 +229,12 @@ as_tibble.default <- function(x, ...) {

#' @export
#' @rdname as_tibble
as.tibble <- function(x, ...) {
Copy link
Contributor Author

@anhqle anhqle Aug 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My way of adding as.tibble as an alias is simply UseMethod(as_tibble). In contrast, as_data_frame is added in a more complicated way:

as_data_frame <- function(x, ...) {

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

Is there any reason to go this more complicated route?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your way creates a new function, the existing alias is just that. The differences are subtle and perhaps unimportant, but we should strive for consistency here. I'm surprised that UseMethod("as_tibble") works here -- I'd have thought it should read UseMethod("as_data_frame").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I'll change as.tibble alias to match as_data_frame alias.

Could you explain why you find it surprising that UseMethod("as_tibble") works? This way the newly created as.tibble generic dispatches to the methods of as_tibble generic. How would it be different from dispatching to the methods of as_data_frame generic?

@krlmlr krlmlr closed this in b274bf7 Aug 29, 2016
Copy link

krlmlr commented Aug 29, 2016

Thanks. I totally forgot that the complicated implementation of as_data_frame() is due to compatibility reasons with code that implements this generic. Merged manually but reverted your last commit.

krlmlr added a commit that referenced this pull request Aug 29, 2016
- Add `as.tibble()` as an alias to `as_tibble()` (#160, @LaDilettante).
- Added tests for `tibble_width()` and `tibble_glimpse_width()` (#163, @LaDilettante).
@anhqle anhqle deleted the add-as_tibble-alias branch August 29, 2016 21:10
krlmlr added a commit that referenced this pull request Apr 1, 2017
Bug fixes

- Time series matrices (objects of class `mts` and `ts`) are now supported in `as_tibble()` (#184).
- The `all_equal()` function (called by `all.equal.tbl_df()`) now forwards to `dplyr` and fails with a helpful message if not installed. Data frames with list columns cannot be compared anymore, and differences in the declared class (`data.frame` vs. `tbl_df`) are ignored. The `all.equal.tbl_df()` method gives a warning and forwards to `NextMethod()` if `dplyr` is not installed; call `all.equal(, ...)` to avoid the warning. This ensures consistent behavior of this function, regardless if `dplyr` is loaded or not (#198).

Interface changes

- Now requiring R 3.1.0 instead of R 3.1.3 (#189).
- Add `as.tibble()` as an alias to `as_tibble()` (#160, @LaDilettante).
- New `frame_matrix()`, similar to `frame_data()` but for matrices (#140, #168, @LaDilettante).
- New `deframe()` as reverse operation to `enframe()` (#146, #214).
- Removed unused dependency on `assertthat`.



- Keep column classes when adding row to empty tibble (#171, #177, @LaDilettante).
- Singular and plural variants for error messages that mention a list of objects (#116, #138, @LaDilettante).
- `add_column()` can add columns of length 1 (#162, #164, @LaDilettante).

Input validation

- An attempt to read or update a missing column now throws a clearer warning (#199).
- An attempt to call `add_row()` for a grouped data frame results in a helpful error message (#179).


- Render Unicode multiplication sign as `x` if it cannot be represented in the current locale (#192, @ncarchedi).
- Backtick `NA` names in printing (#206, #207, @jennybc).
- `glimpse()` now uses `type_sum()` also for S3 objects (#185, #186, @holstius).
- The `max.print` option is ignored when printing a tibble (#194, #195, @t-kalinowski).


- Fix typo in `obj_sum` documentation (#193, @etiennebr).
- Reword documentation for `tribble()` (#191, @kwstat).
- Now explicitly stating minimum Rcpp version 0.12.3.


- Using registration of native routines.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

Successfully merging this pull request may close these issues.

Would be nice to have as.tibble too.
3 participants