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

Feature request: Allow further customisation of kable() table header #2024

Closed
3 tasks done
mruessler opened this issue Jul 13, 2021 · 3 comments · Fixed by #2180
Closed
3 tasks done

Feature request: Allow further customisation of kable() table header #2024

mruessler opened this issue Jul 13, 2021 · 3 comments · Fixed by #2180
Labels
help needed We need your help with the issue/PR

Comments

@mruessler
Copy link

mruessler commented Jul 13, 2021

I would like to be able to create tables in the style that Jira is using. Jira uses a slightly different version of the knitr::kable(format = "pipe") output. Instead of having a header line separated by a data-void line, two consecutive pipe symbols are used.

# Hand-crafted table from BOD data
|| Time|| demand||
|     1|     8.3|
|     2|    10.3|
|     3|    19.0|
|     4|    16.0|
|     5|    15.6|
|     7|    19.8|

See also https://stackoverflow.com/questions/68308461 for an example. This links to a SO question I asked.
Since then I looked into table.R in order to find out whether I could use additional parameters for a call to kable().
But it looks like this is currently impossible. Then I wanted to at least remove the separator line between header and table body using sep.row from kable_mark() to spare me the removal later. This is what I tried:

data("BOD")
y <- head(BOD)
knitr::kable(y, format = "pipe", sep.row = c(NA, NA, NA))
> Error in if (sep.col == "|") for (j in seq_len(ncol(x))) { : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In if (sep.col == "|") for (j in seq_len(ncol(x))) { :
  the condition has length > 1 and only the first element will be used

The parameter sep.row is probably not meant for use like this. But it would really help me to be able to fine-tune the table output. Jira might be my itch but there may be other formats that cannot currently created as well. I hope that I did not overlook a solution already present.
In summary:

  • the option sep.row would be nice, and
  • a new option to change the separator for the first line would be great ;-)
> xfun::session_info('knitr')
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043), RStudio 1.4.1717

Locale:
  LC_COLLATE=English_United Kingdom.1252 
  LC_CTYPE=English_United Kingdom.1252   
  LC_MONETARY=English_United Kingdom.1252
  LC_NUMERIC=C                           
  LC_TIME=English_United Kingdom.1252    

Package version:
  evaluate_0.14   glue_1.4.2      graphics_4.1.0  grDevices_4.1.0
  highr_0.9       knitr_1.33      magrittr_2.0.1  markdown_1.1   
  methods_4.1.0   mime_0.11       stats_4.1.0     stringi_1.6.2  
  stringr_1.4.0   tools_4.1.0     utils_4.1.0     xfun_0.24      
  yaml_2.2.1     

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('knitr'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/knitr').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@yihui
Copy link
Owner

yihui commented Jul 26, 2021

Thanks for the request! I'm afraid that I won't have time to implement this by myself, but I can probably review a pull request if someone sends one.

@yihui yihui added the help needed We need your help with the issue/PR label Mar 24, 2022
@yihui yihui linked a pull request Oct 6, 2022 that will close this issue
yihui added a commit that referenced this issue Oct 6, 2022
Co-authored-by: Yihui Xie <xie@yihui.name>
@yihui
Copy link
Owner

yihui commented Oct 6, 2022

This has been implemented in the dev version, thanks to the contribution by @pedropark99.

You can test the development version via

remotes::install_github('yihui/knitr')

Then kable(format = 'jira') should generate the table for you.

Thanks!

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@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
help needed We need your help with the issue/PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants