ianmoran11/mmtable2

Automate the borderline after use header_left_top

Closed this issue · 4 comments

Thank you for this amazing work. I find it is a little bit frustrated to set the position of borderline manually after use header_left_top, as shown in the example code in README. All the numbers will be changed if the data is updated, which makes it hard to reproduce a similar table using updated data.

I'm wondering if it is possible to automate these borderlines based on the position of the headers and allow users to decide the style of the border through arguments inside of the header_left_top function.

Or maybe even better, wrap all these arguments for styling into a theme function with some pre-defined themes, like in ggplot2.

Hi Albert. Thanks for the feedback and suggestions.

I'm thinking that the most straight forward approach would be to add a scope argument to header_format, where scope indicates whether the formatting is just applied to the header cell or across the whole table (the entire row in this case).

The example from the readme would look something like:

  mmtable(cells = value) +
   .... +
  header_format(continent, scope = "table",style = style_list)

I like the idea of a theme function too --- not sure how to implement it just yet.

Hi Albert. Thanks for the feedback and suggestions.

I'm thinking that the most straight forward approach would be to add a scope argument to header_format, where scope indicates whether the formatting is just applied to the header cell or across the whole table (the entire row in this case).

The example from the readme would look something like:

  mmtable(cells = value) +
   .... +
  header_format(continent, scope = "table",style = style_list)

I like the idea of a theme function too --- not sure how to implement it just yet.

Hi Ian, I think it is a good idea! For theme, I think it is just a wrapper function that can be used to define/overwrite the styling factors like font family, font size, background color ... etc. What I really like about this package is that it uses a similar logic as ggplot, just not as sophisticated yet. I really think this is a missing part of the tidyverse and hope this package can go big!

Hi @albert-ying,

I've added this feature in the feature-header-format branch. I'm planning to move it over to the master branch after testing it a bit more.

Until then you'll need to install from feature-header-format to try it out.

Here's an example using the scope argument. It takes either "cell", "headers" or "table".

`gm_df <- gapminder_mm %>% filter(var != "Life expectancy")
style_list <- list(cell_borders(sides = "top",color = "grey"))

gm_table <-
gm_df %>%
mmtable(cells = value) +
header_left(year) +
header_top(country) +
header_left_top(var) +
header_top_left(continent) +
header_format(var, scope = "table", style = style_list)

gm_table
`

Screenshot from 2021-07-10 10-45-46

It looks great! I will close this issue.