Questions tagged [kableextra]

kableExtra is an R package that helps to build common complex tables (in both HTML and pdf) and manipulate table styles. Using the pipe %>% symbol one can add "layers" to a kable output to get a well-formatted table.

680 questions
28
votes
2 answers

Coloring rows with kableExtra based on cell values

I use R markdown in combination with LaTeX to create PDF reports. To generate tables I use the kableExtra package. I'd like to change the styling of rows based on the values in a particular column. I've been trying cell_spec, but as far as I can see…
SPK.z
  • 383
  • 1
  • 3
  • 8
25
votes
2 answers

Replace column names in kable/R markdown

My data frame has ugly column names, but when displaying the table in my report, I want to their "real" names including special characters '(', new lines, greek letters, repeated names, etc. Is there an easy way of replacing the names in knitr to…
Dr Dave
  • 453
  • 1
  • 4
  • 11
20
votes
3 answers

How to format kable table when knit from .rmd to Word (with bookdown)

I have read the bookdown book and still cannot figure this out. I am trying to create a Word report through bookdown. I want to use kableExtra to add striping to my tables and also to bold my last table row. Can kableExtra be used when knitting to…
JHawkins
  • 243
  • 1
  • 2
  • 10
17
votes
4 answers

Why does rendering a pdf from rmarkdown require closing rstudio between renders?

Background I am trying to make a rmarkdown document that is rendered using render(). The render call has two elements that are parameterized: I would like the user to be able to specify pdf or html. Straightforward using output_format(). I also…
boshek
  • 4,100
  • 1
  • 31
  • 55
15
votes
1 answer

Change Border Color of Border on Table- Kable

I am trying to create borders around specific columns in R. I am able to do this using the kableExtra package (shown below) iris <- datasets::iris iris2 <- do.call(data.frame, aggregate(. ~ Species, iris, function(x) c(mean = mean(x), sd =…
daszlosek
  • 1,366
  • 10
  • 19
14
votes
1 answer

How to set knitr::kable() global options in markdown for reuse

Is there an easy to use way to setup custom default kable() options, so that there is no need in rewriting them for each kable() call. For example, my usual table styling uses following code: library(kableExtra) kable(mtcars, booktabs=TRUE, digits=…
blazej
  • 1,678
  • 3
  • 19
  • 41
14
votes
2 answers

Controlling row height in kableExtra()

Hi i made this awesome table with kableExtra, but my only problem is that the height of the rows is not always equal. Does any one know a remedy for this? my table: for example, as you can see, the line for item number 22 (6th row) has a larger…
Benjamin Telkamp
  • 1,451
  • 2
  • 17
  • 31
13
votes
1 answer

row_spec() function from kableExtra does not create a horizontal line in html output

I would like to add a horizontal line under one of the rows in my kableextra table. The parameter hline_after for row_spec function is supposed to add the horizontal line under the row: row_spec documentation However, this does not happen, the…
tadej
  • 400
  • 1
  • 2
  • 11
13
votes
1 answer

how to cross reference tables and plots in rmarkdown?

I am using the following template --- title: "Nice try buddy" author: "SpaceMan" date: "13 December 2057" output: bookdown::pdf_document2 header-includes: - \usepackage{booktabs} - \usepackage{longtable} - \usepackage{array} -…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
13
votes
2 answers

kableExtra: Dynamic add_header_above labeling

I would like to create a pdf with rmarkdown. The PDF should contain a table. The table should have a dynamic column label. The tabhead should display the calendar week. However, the calendar week (e.g., KW29) is not displayed but the variable name…
Rene
  • 281
  • 2
  • 8
12
votes
1 answer

Error when loading kableExtra in markdown file after updating to R 4.3.0

After updating to R 4.3.0 (on macOS 13.3.1) I get an error message, when compiling a markdown document: Error: package or namespace load failed for 'kableExtra': .onLoad failed in loadNamespace() for 'kableExtra', details: …
Chris
  • 327
  • 3
  • 11
12
votes
1 answer

How to format all numbers in a table in r using kable?

I need to be able to reduce or simplify the numbers in this table. I want only up to 4 decimal places shown and if possible only integers if the number is a whole number. How would I accomplish this? library(kableExtra) x = c(1, 1, 1, 1, 1, 1, 1,…
LegendOfKass
  • 181
  • 2
  • 3
  • 8
12
votes
2 answers

How to make kable table reactive() in shiny app? Shiny + kable

I am trying to make kable table reactive and export it in shiny app. already gave a try with renderDataTable/renderTable inside server and output functions as datatableOutput/tableOutput, but of no luck and following is the line of code. …
Dinesh
  • 391
  • 2
  • 9
12
votes
1 answer

left- align table caption with kable or kableExtra

Is it possible to left-align the table caption? I am annoyed by the APA6th rules but I have to left-align the table caption somehow. Take for example this table: library(knitr) library(kableExtra) kable(mtcars[1:10, 1:6], format = "latex",…
Jaynes01
  • 521
  • 1
  • 5
  • 20
10
votes
1 answer

Prevent pagebreak in kableExtra landscape table

How can a landscape table be plotted in R Markdown (PDF output) without causing a page break to be inserted? There is the function landscape from the kableExtra package, but this forces a page break to be inserted. Example: The normal behaviour for…
Michael Harper
  • 14,721
  • 2
  • 60
  • 84
1
2 3
45 46