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
48
votes
3 answers

Space after every five rows in kable output (with booktabs option) in R Markdown document

I am using knitr::kable() to render tables as part of an R Markdown document (that itself is part of a bookdown project). In particular, the booktabs option (through setting the booktabs argument to equal TRUE) renders the table in a nice-looking…
Joshua Rosenberg
  • 4,014
  • 9
  • 34
  • 73
35
votes
2 answers

Scale kable table to fit page width

How do you format a table in pdf using kable function? Because my output table width exceeds the width of the pdf. Here is an example: --- output: pdf_document --- ```{r} df <- cbind(mtcars[1:5,], mtcars[1:5,]) knitr::kable(df) ```
Bustergun
  • 977
  • 3
  • 11
  • 17
35
votes
4 answers

Aligning Columns with knitr kable function

I am performing a simple task: creating a table and outputting it using R Markdown to pdf as follows: library(knitr) kable(datatable,align='ccccccc', col.names = c("Copy","Sigma Est","Sigma Lower","Sigma Upper", "Lambda Est","Lambda Lower","Lambda…
Kivis
  • 924
  • 2
  • 10
  • 20
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
28
votes
3 answers

Rmarkdown setting the position of kable

I have the following issue, once knitting the Rmarkdown in Rstudio to PDF, my tables appear not in the position where they are in Rmarkdown file, but on the top of the page. I tried to add: header-includes: - \usepackage{float} and ```{r setup,…
Justas Mundeikis
  • 935
  • 1
  • 10
  • 19
26
votes
0 answers

rmarkdown using kable with list of data.tables loses table formatting

I have a rmarkdown document where I want to use a list of data.tables and include them in a PDF/HTML/MS Word document. Each component of the list contains one data.table. What I'm trying to achieve is to use kable to add all tables in a document…
panman
  • 1,179
  • 1
  • 13
  • 33
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
21
votes
1 answer

Short caption in knitr::kable()

How can I create a short caption in kable? library(dplyr) library(knitr) library(kableExtra) df <- data.frame( X = sample(letters, 10), y = runif(10), z = sample(10:20, 10)) kable(df, booktabs = TRUE, caption = "This caption is way too…
Caddisfly
  • 1,290
  • 6
  • 24
20
votes
1 answer

How to remove/hide column names in kable?

I am plotting a table using following code but I found there is unnecessary column names V1 and V2 appear as column name. statdat<-read.table("stat.txt",sep="\t",header=FALSE) kable(statdat) How can I avoid printing the column name?
Manish
  • 3,341
  • 15
  • 52
  • 87
14
votes
0 answers

Knitr/kable: table moving to the end of page when adding caption/figure label

I'm somewhat new to R Markdown, so apologies if this is silly. I'm preparing a pdf report using R Markdown/Knitr, and running into a problem where, if I try to include a styled table using kable, it moves the table to the bottom of the page. Here…
Maria M
  • 141
  • 1
  • 5
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
2 answers

wrap text in knitr::kable table cell using "\n"

How can I wrap a cell in a knitr::kable table cell using \n? I want to generate a .rmd file containing some tables where one column needs text wrapping. The places where the wrapping should occur are marked with \n. I tried (this is a standalone…
symbolrush
  • 7,123
  • 1
  • 39
  • 67
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
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
1
2 3
52 53