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

Redesign tibble formatting #235

Closed
7 of 9 tasks
krlmlr opened this issue Apr 17, 2017 · 3 comments
Closed
7 of 9 tasks

Redesign tibble formatting #235

krlmlr opened this issue Apr 17, 2017 · 3 comments

Comments

@krlmlr
Copy link
Member

krlmlr commented Apr 17, 2017

with the following goals:

  • extensibility
  • clear responsibility between tibble, dplyr, and others
  • separate printing/formatting of individual components (header, footer, ...)
  • separation of the logic for formatting the columns
  • support for format()
  • configurable formatting for the body (and perhaps also header/footer)
  • format() and print(): full support for Unicode everywhere
  • glimpse(): full support for Unicode everywhere
  • support for both dplyr 0.5.0. and dplyr 0.6.0

Something like:

  1. We implement print() by forwarding to format()
  2. format.tbl_df() calls format_head(), format_body() and format_extra(), default implementations are provided for tibbles
    • we cannot rely on format.data.frame() because it returns a data frame and not a character vector
  3. dplyr needs to implement only format_head() for grouped data frames, and can append its information to the result of NextMethod()

The current implementation is inflexible because it relies on format.data.frame(). Therefore, this issue is mostly about replacing format.data.frame() with our own implementation.

We should release just before the dplyr release. I'll be closing a few related issues with a reference to this new issue.

@hadley: Could you please comment?

@hadley
Copy link
Member

hadley commented Apr 17, 2017

That design sounds good.

Maybe format_tail() for consistency? Or format_header() and format_footer()?

krlmlr added a commit that referenced this issue Apr 19, 2017
- Own printing routine, not relying on `print.data.frame()` anymore. Now providing `format.tbl_df()` and full support for Unicode characters in names and data (#235).
krlmlr added a commit that referenced this issue Apr 19, 2017
- Own printing routine, not relying on `print.data.frame()` anymore. Now providing `format.tbl_df()` and full support for Unicode characters in names and data (#235).
- Minor efficiency gains by replacing `any(is.na())` with `anyNA()` (#229, @csgillespie).
- Using `rlang` instead of `lazyeval` (#225, @lionel-).
krlmlr added a commit that referenced this issue May 9, 2017
- `glimpse()` now properly displays tibbles with foreign characters in
  column names (#235).
@krlmlr
Copy link
Member Author

krlmlr commented May 9, 2017

Reopening the unresolved issues.

@krlmlr krlmlr closed this as completed May 9, 2017
krlmlr added a commit that referenced this issue May 13, 2017
- The `print()`, `format()`, and `tbl_sum()` methods are now implemented for class `"tbl"` and not for `"tbl_df"`. This allows subclasses to use tibble's formatting facilities. The formatting of the header can be tweaked by implementing `tbl_sum()` for the subclass.
- New `set_tidy_names()` and `tidy_names()`, a simpler version of `repair_names()` which works unchanged for now (#217).
- Printing now uses `x` again instead of the Unicode multiplication sign, to avoid encoding issues (#216).
- `glimpse()` now properly displays tibbles with foreign characters in column names (#235).
krlmlr added a commit that referenced this issue May 17, 2017
- Subsetting zero columns no longer returns wrong number of rows (#241, @echasnovski).

- New `set_tidy_names()` and `tidy_names()`, a simpler version of `repair_names()` which works unchanged for now (#217).
- New `rowid_to_column()` that adds a `rowid` column as first column and removes row names (#243, @barnettjacob).
- The `all.equal.tbl_df()` method has been removed, calling `all.equal()` now forwards to `base::all.equal.data.frame()`. To compare tibbles ignoring row and column order, please use `dplyr::all_equal()` (#247).

- Printing now uses `x` again instead of the Unicode multiplication sign, to avoid encoding issues (#216).
- String values are now quoted when printing if they contain non-printable characters or quotes (#253).
- The `print()`, `format()`, and `tbl_sum()` methods are now implemented for class `"tbl"` and not for `"tbl_df"`. This allows subclasses to use tibble's formatting facilities. The formatting of the header can be tweaked by implementing `tbl_sum()` for the subclass, which is expected to return a named character vector. The `print.tbl_df()` method is still implemented for compatibility with downstream packages, but only calls `NextMethod()`.
- Own printing routine, not relying on `print.data.frame()` anymore. Now providing `format.tbl_df()` and full support for Unicode characters in names and data, also for `glimpse()` (#235).

- Improve formatting of error messages (#223).
- Using `rlang` instead of `lazyeval` (#225, @lionel-), and `rlang` functions (#244).
- `tribble()` now handles values that have a class (#237, @NikNakk).
- Minor efficiency gains by replacing `any(is.na())` with `anyNA()` (#229, @csgillespie).
- The `microbenchmark` package is now used conditionally (#245).
- `pkgdown` website.
@github-actions
Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants