kable

wrap text in knitr::kable table cell using “\n”

只愿长相守 提交于 2019-12-12 12:24:22
问题 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 .rmd document): --- output: pdf_document --- ## A Table with text wrap ```{r cars} knitr::kable(data.frame(col1 = c("a", "b"), col2 = c("one\ntwo", "three\nfour"))) ``` ..but this doesn't work. Instead of staying in col2 , the wrapped part lives on

R-Markdown - kableExtra package - format = 'latex' not working

て烟熏妆下的殇ゞ 提交于 2019-12-12 04:59:22
问题 Using the kableExtra documentation. inside RMardown I am running: ```{r} library(knitr) library(kableExtra) dt <- mtcars[1:5, 1:6] kable(dt, format = "rmarkdown") ``` this actually outputs a table but I also get the following in the console: Error in kable_rmarkdown(x = c("Mazda RX4", "Mazda RX4 Wag", "Datsun 710", : could not find function "kable_rmarkdown" when I switch to: ```{r} library(knitr) library(kableExtra) dt <- mtcars[1:5, 1:6] kable(dt, format = "latex") ``` I get no error and no

how to use a for loop in rmarkdown?

狂风中的少年 提交于 2019-12-12 00:57:27
问题 Consider this simple example: --- title: "Untitled" output: ioslides_presentation --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) ``` ## Slide with R Output ```{r t, warning=FALSE, message=FALSE} library(knitr) library(kableExtra) library(dplyr) for(threshold in c(20, 25)) { cars %>% filter(dist < threshold) %>% kable('html') %>% kable_styling(bootstrap_options = "striped") } ``` Here I simply want to print each output of the for loop into a different slide. In this

Error in kable and kableExtra in R Markdown

瘦欲@ 提交于 2019-12-11 16:38:05
问题 I am trying to learn to use kable and kableExtra to generate an html document from a shiny app. The code goes something like this: orthoInstructions <- special_ortho_table() kable(orthoInstructions, "html", booktabs = T) %>% kable_styling(full_width = FALSE, position = "center") The output depends on the special_ortho_table() in the app and generates a table of varying number of rows but the number of columns are always the same - two. However, whenever I try to add something more to this to

RMarkdown - different font types in table using kable?

人盡茶涼 提交于 2019-12-11 16:08:06
问题 I am using RMarkdown to produce pdf document. Is it possible to change font type in tables using kable_styling? If not, could you suggest any other package? library(dplyr) library(kableExtra) kable(mtcars, align = "c", booktabs = TRUE) %>% kable_styling(font_size = 12) %>% row_spec(0, bold = T, color = "white", background = "gray") 回答1: This is somewhat tricky, because changing fonts in LaTeX is tricky. I don't have the Segoe UI font (that's a Windows font, right?), but here's something that

kableExtra: Put a few rows of a table into many categories programmatically

风格不统一 提交于 2019-12-11 15:11:01
问题 Currently kableExtra 0.5.1 only supports Put a few rows of a table into one category . I wonder if there is any tweak to Put a few rows of a table into many categories programmatically like group_rows(kable_input = x, group_label = c("Group 1", "Group 2"), start_row = c(1, 5), end_row = c(2, 6)) . Thanks library(knitr) library(kableExtra) x <- knitr::kable(head(mtcars, 10), "latex") kableExtra::group_rows(kable_input = x, group_label = c("Group 1", "Group 2"), start_row = c(1, 5), end_row = c

How to specify table stripe colors for knitr::kable?

二次信任 提交于 2019-12-11 08:13:50
问题 How was this person able to make the tables shown in this link? It doesn't look like they were passing any arguments to kable. Here is the example: 回答1: The styles of kable tables are controlled by CSS file. tbody can be used to change the colour of the content of the table, with thead able to change the header. As shown by Lee S, you can create an external CSS file. However, you can also include the CSS directly within the R Markdown file, as markdown accepts raw HTML and passes it through

A Kableextra table and a ggplot plot on same row in Rmarkdown (PDF - not Flexdashboard)

心已入冬 提交于 2019-12-11 05:57:13
问题 I have been experimenting with R Markdown to create some PDF reports. I am having difficulty in getting the layout right. Basically, I need to have a KableExtra created table (dataframe) and a ggplot plot on the same row. I have explored some grid packages, but couldn't get it to work. Here is my code: --- title: "Untitled" author: "" date: "14 June 2018" output: pdf_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) library(knitr) library(reshape2) library(dplyr)

Is there a way to make a kable without lines/borders for pdf?

牧云@^-^@ 提交于 2019-12-11 00:42:56
问题 I'm working on a shiny-app that produces and sends a pdf-report, containing the wrangled data. The problem is that I can't get the table layout to look as the client want it to look. The client wants the tables to lack lines/borders except ontop of the last row, is this possible in kable and/or kableExtra? No answers containing other packages please, as I'm aware that of xtable. table.tbl <- tibble(var1 = c("entry 1", "entry 2", "entry 3", "entry 4"), var2 = c(2000, 1000, 3000, 200), var3 = c

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