kableextra

Make NA values in table just blank cells when using cell_spec in kableExtra [duplicate]

社会主义新天地 提交于 2019-12-13 20:25:36
问题 This question already has answers here : Hiding NA's when printing a dataframe in knitr (2 answers) Closed 7 months ago . Following on from a previous question, I am using the cell_spec function from kableExtra to change the background color of cells within a table. How can you remove the NA text and color the background white for the NA cells so that an NA appears just as a blank cell? Below is my example table with the NA cells. In real life there is a dynamic number of columns with various

Kable caption in rmarkdown file in HTML in bold

爱⌒轻易说出口 提交于 2019-12-13 03:33:05
问题 I want to make my table caption in bold but can't seem to find the option for it. My code is (in a rmarkdown document): kable(head(iris), caption = 'I want this in Bold') %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) The output is: 回答1: Does this markdown-oriented solution work for you? ```{r, results='asis'} kable(head(iris), caption = '**I want this in Bold**') %>% kableExtra::kable_styling(bootstrap_options = c("striped", "hover", "condensed",

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

R wanting to limit the amount of digits from csv file

点点圈 提交于 2019-12-11 19:03:39
问题 There are plenty of threads about people thinking they have lost digits when reading in a csv file, and it's just a digits setting that isn't displaying all of them. I on the other hand want to round or truncate my incoming data to two decimal places. I am having an issue in Rmarkdown where I can't limit the decimal places after highlighting fields. This has lead to me attempting to round before the highlighting, but that leads to undesirable results if I go lower than 4 places since I am

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

Create hyperlink in table and adjust column to wrap text Rmarkdown

删除回忆录丶 提交于 2019-12-11 05:18:44
问题 I am trying to create hyperlinks inside a table and also adjust columns to wrap text and generate pdf. Ex table: variable<-"testing a long column to wrap testing a long column to wrap " col1<-"\href{https://www.google.co.uk/}{click here}" col2<-"[click here](https://www.google.co.uk/)" col3<-"[click here](https://www.google.co.uk/)" col4<-"[click here](https://www.google.co.uk/)" col5<-"[click here](https://www.google.co.uk/)" test<-data.frame(variable,col1,col2,col3,col4,col5) When I tried

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