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 a new output format "jira" to kable() - Issue #2024 #2180

Merged
merged 16 commits into from
Oct 6, 2022

Conversation

pedropark99
Copy link
Contributor

@pedropark99 pedropark99 commented Oct 1, 2022

Hello! This PR seeks to fulfill the request made in the issue #2024 . It adds a new output format to kable(), more specifically, a "jira" format. A simple example:

tab = head(ggplot2::mpg)
knitr::kable(tab, format = 'jira')


||manufacturer ||model || displ|| year|| cyl||trans      ||drv || cty|| hwy||fl ||class   ||
|audi         |a4    |   1.8| 1999|   4|auto(l5)   |f   |  18|  29|p  |compact |
|audi         |a4    |   1.8| 1999|   4|manual(m5) |f   |  21|  29|p  |compact |
|audi         |a4    |   2.0| 2008|   4|manual(m6) |f   |  20|  31|p  |compact |
|audi         |a4    |   2.0| 2008|   4|auto(av)   |f   |  21|  30|p  |compact |
|audi         |a4    |   2.8| 1999|   6|auto(l5)   |f   |  16|  26|p  |compact |
|audi         |a4    |   2.8| 1999|   6|manual(m5) |f   |  18|  26|p  |compact |

To achieve this new functionality, a new argument called sep.head.col in kable_mark(), and a new function called kable_jira() were added. This argument defines the separator between each column in the header of the table (i.e. the line with the column names). With format = "jira", this argument will be set to sep.head.col = "||".

If the user does not provide a value (or give a NA value) for the argument sep.head.col, it will be automatically set to the sep.col value. Because of this behaviour, in other output formats, like "pipe" or "simple", the sep.head.col argument will be equal to sep.col:

https://github.com/pedropark99/knitr/blob/2024-jira-kable/R/table.R#L393-L394

So kable_jira() basically uses kable_mark() with sep.head.col = "||" to build the output table. By adding this new sep.head.col argument to kable_mark(), we might create more flexibility to add new styles and formats in the future for kable().

Thank you for the attention!

Copy link
Owner

@yihui yihui left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@yihui yihui linked an issue Oct 6, 2022 that may be closed by this pull request
3 tasks
@yihui yihui merged commit b3936ca into yihui:master Oct 6, 2022
@yihui yihui changed the title Add a new output format to kable() - Issue #2024 Add a new output format "jira" to kable() - Issue #2024 Oct 11, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Allow further customisation of kable() table header
2 participants