Questions tagged [kable]

Create Tables In LaTeX, HTML, Markdown And ReStructuredText

A function from R knitr package by Yihui Xie.

This is a very simple table generator. It is simple by design. It is not intended to replace any other R packages for making tables.

Related tags:

795 questions
6
votes
3 answers

How to limit the number of rows printed in kable

When using rmarkdown to render pdf document, we can use three options for printing data.frame: default, kable and tibble (see here) With the default option, it is possible to limit the number of rows printed, with the option: max.print For tibble,…
John Smith
  • 1,604
  • 4
  • 18
  • 45
6
votes
5 answers

kableExtra column_spec width not working

I am creating tables that will be rendered using Rmarkdown to HTML. I am using kable and have been experimenting with kableExtra to add features to my tables. I am not able to get the width option in column_spec to work when applying it to all…
kr32
  • 63
  • 1
  • 4
6
votes
1 answer

knitr::kable outputs code instead of a pretty table

I recently updated to R 3.5.0 and RStudio 1.1.453 and now my kable function is not working properly. When I copy and paste the code and output, you see this: library(knitr) fakedata<-data.frame(Species = c(1:8), Sites = sample(1:25, 8, replace =…
P Motyka
  • 61
  • 3
6
votes
2 answers

R - kable() used in .Rmd does not show output in notebook

I just started using kableExtra library to make my tables look better in the PDF output. But when I use kable() function in R Notebook file, it does not show the output. Instead I see a large white space where the output should be. Here is a…
jmich738
  • 1,565
  • 3
  • 24
  • 41
6
votes
3 answers

Is it possible to remove horizontal lines in Kable kableextra with html option?

I am trying to create a table using kable/kableextra without showing the horizontal lines in the table except for the first row which is the row names. ``` {r echo=FALSE} library(knitr) library(kableExtra) options(knitr.kable.NA = '') dt <-…
Stephen Lien
  • 221
  • 1
  • 2
  • 3
6
votes
0 answers

Easy way to rmarkdown between HTML and Word output?

I have created some tables (using knitr & kableExtra) that work well when I use output: html_document but when I try to render them with output: word_document the content of each cell in the tables prints onto successive new lines in the Word…
Dom
  • 1,043
  • 2
  • 10
  • 20
6
votes
0 answers

Latex symbols in rmarkdown table using knitr::kable

I am trying to use knitr::kable in Rmarkdown to create a table of latex equations. However, I am having difficulties getting special characters such as $\sum$ or $\hat$ to work. For example the following works: knitr::kable(head(mtcars[,c(1,2)],…
Grant Adams
  • 61
  • 1
  • 2
5
votes
2 answers

How to force linebreaks in kableExtra functions with escape = FALSE?

In kableExtra >= 0.8.0, the canonical way to insert a linebreak into text piped into a table from a kableExtra function such as add_header_above or pack_rows is to add an \n directly. However, this appears not to work with the escape = FALSE…
Westcroft_to_Apse
  • 1,503
  • 4
  • 20
  • 29
5
votes
2 answers

R kable/kableExtra, conditional formatting by percentage (with missing values)

I am using kable and kableExtra and want to display a table with columns of percentages (in format "95%"). I would also like to do conditional formatting of the cell backgrounds based on the percent value (with multiple colors and cut points). In…
Megan C
  • 53
  • 1
  • 3
5
votes
2 answers

Is there any possibility to save kable table in .tex or .markdown?

Let's consider very simple kable table for reproducible example: df <- data.frame("X_1" = c(1, 2), "X_2" =c(3,4)) df <- kable(df, format = 'latex') df \begin{tabular}{r|r} \hline X\_1 & X\_2\\ \hline 1 & 3\\ \hline 2 & 4\\ \hline \end{tabular} Is…
John
  • 1,849
  • 2
  • 13
  • 23
5
votes
1 answer

R knitr kable order rows by one column first, then by another

Hello all and a happy new year, I have a table of the accuracy and kappa output of different learning models and am using knitr::kable to display them. I now want to order the models (rows) first by accuracy (highest at top to lowest at bottom) and…
corkinabottle
  • 141
  • 1
  • 7
5
votes
1 answer

How to build a two-way table summarizing a third variable in R (kable package)

I am working with RMarkdown and trying to use kable package. I have a three-variable data frame: gender (factor), age_group (factor), and test_score(scale). I want to create two-way tables with factor-variables (gender and age_groups) as table rows…
LuizZ
  • 945
  • 2
  • 11
  • 23
5
votes
2 answers

How do I prevent kable from leaving raw latex in the final document if I include a caption in a table?

I'm writing my thesis in Rmarkdown (specifically bookdown) and using knitr to compile it into a PDF. When I knit it, everything works perfectly other than the tables and figures. The tables (produced with kable) look almost perfect, but are wrapped…
5
votes
1 answer

r - use kable to group columns with sub columns having the same name

I am trying to use kable and kableextra to create a table that has different grouped headers but the same column names in the sub-headers For example, if you look at the section "Grouped Columns/Headers" (page 14) of Create Awesome LaTeX Table with…
alexb523
  • 718
  • 2
  • 9
  • 26
5
votes
0 answers

How to apply kable_styling to all code chunks in R Markdown with HTML output?

I'm currently using the following kable_styling() from kableExtra: kable_styling(bootstrap_options = c("striped", "hover", "condensed")) I can set the table style to kable in my R Markdown document in the YAML metadata as follows: output: …
pomodoro
  • 297
  • 3
  • 12