kableextra

For Loop for Creating Multiple Tables using knitr and kableExtra packages in RMarkdown

不羁的心 提交于 2019-12-08 02:39:20
问题 I need to create multiple tables in RMarkdown and style it with the kableExtra package. As an example, I have the iris dataset. My first table displays the first 20 rows, my second table the next 20 rows, and my third table next 20 rows... Below is the code: --- title: "" output: pdf_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) ``` ```{r} library(knitr) library(kableExtra) landscape(kable_styling(kable(iris[1:20, ], format = "latex", align = "c", row.names =

Change font of Kable in Rmarkdown pdf

拈花ヽ惹草 提交于 2019-12-07 17:09:20
问题 Is there a way to change the font of a kable in Rmarkdown when knitting to pdf? I can find plenty on changing size or bold etc but not on changing the actual font. I would just like something sans serif. Example markdown doc: --- title: "R Notebook" output: pdf_document: default --- Change the font in the table below: ```{r message=FALSE, warning=FALSE, echo=FALSE} library(kableExtra) mtcars %>% head() %>% kable() ``` Default table output font 回答1: You can use the Latex fontspec library, see

Vertical align kable's column name

余生长醉 提交于 2019-12-07 13:56:18
问题 Suppose the next example: library(knitr) library(kableExtra) df <- data.frame(a = letters[1:10], b = 1:10) names(df) <- c("This is a looooooong title, I don't know how to handle this... Also, I'm trying to extend this title even more... This column name will be used to compute vertical space","I want to align vectically this column name") df %>% kable(format = 'latex', linesep = "", align = 'c') %>% kable_styling(full_width = T) How can align vertically the second column name? 回答1: I am not

Vertical align kable's column name

不问归期 提交于 2019-12-06 01:29:10
Suppose the next example: library(knitr) library(kableExtra) df <- data.frame(a = letters[1:10], b = 1:10) names(df) <- c("This is a looooooong title, I don't know how to handle this... Also, I'm trying to extend this title even more... This column name will be used to compute vertical space","I want to align vectically this column name") df %>% kable(format = 'latex', linesep = "", align = 'c') %>% kable_styling(full_width = T) How can align vertically the second column name? I am not sure if there is an easier way, but you can go with the multirow package: --- title: "Test Book" header

Change font of Kable in Rmarkdown pdf

馋奶兔 提交于 2019-12-05 21:35:12
Is there a way to change the font of a kable in Rmarkdown when knitting to pdf? I can find plenty on changing size or bold etc but not on changing the actual font. I would just like something sans serif. Example markdown doc: --- title: "R Notebook" output: pdf_document: default --- Change the font in the table below: ```{r message=FALSE, warning=FALSE, echo=FALSE} library(kableExtra) mtcars %>% head() %>% kable() ``` Default table output font You can use the Latex fontspec library , see below. Note that you can see your available fonts and their names in the Fonts page from Settings. ---

KableExtra conditionally formatting specific rows on a column

此生再无相见时 提交于 2019-12-03 21:12:52
I have just learnt KableExtra and know to how to use conditionally formating the entire column using mutate() as explained in the doc using mutate such as: mutate( mpg = cell_spec(mpg, background = ifelse(mpg > 20, "red", "blue")) ) But what I don't know is, how to change background colours of only certain rows in each column whilst all rows are being displayed. For example, my data: df <- data.frame( region1 = c("A", sample(1:5,3)), region2 = c("B", sample(1:5,3)), region3 = c("C", sample(1:5,3)), region4 = c("A", sample(1:5,3)) ) Now I want to format only second and third row. I dont want to

RMarkdown kable vertically align cells

梦想的初衷 提交于 2019-12-01 08:37:24
问题 I am authoring a report using RMarkdown, and using kable and kableExtra to format and print the table. Here is what I want would look like the table to look like (made in Word): I am struggling to sort the vertical centering (the space between "Number of Incident Occurences" on the top and bottom, so that the text is aligned in the middle of the row, left on the column. Note, I am creating a PDF report and not html. Here is a minimal example: df <- data.frame(a = letters[1:5], b = 1:5) names

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

谁说胖子不能爱 提交于 2019-12-01 06:23:57
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 Word ? This is a subset of my code : library(dplyr) knitr::opts_chunk$set(echo = TRUE) library(knitr) # required for kable library(kableExtra) # required for kableExtra options(knit.r.table.format = "markdown") myRegion <- c("a", "b", "c") Current_Perc_1 <- c(85.9, 90.8, 89.7) Current_Perc_2 <- c(88.0, 91.0, 89.0) tab_curr_est_2_times <- cbind

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

回眸只為那壹抹淺笑 提交于 2019-12-01 05:31:25
问题 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 Word ? This is a subset of my code : library(dplyr) knitr::opts_chunk$set(echo = TRUE) library(knitr) # required for kable library(kableExtra) # required for kableExtra options(knit.r.table.format = "markdown") myRegion <- c("a", "b", "c") Current

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

戏子无情 提交于 2019-11-28 18:53:31
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 would like to pass a parameter to the document to specify if the tables (using the kableExtra package) are latex or html. This is the rmarkdown file called test.Rmd --- title: "Title" author: "Zzz Zzzzzz" params: table_format: value --- ```{r setup} knitr::opts_chunk$set(echo = FALSE) library(knitr) library(kableExtra) options(knitr.table.format =