kable

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. ---

Aligning Columns with knitr kable function

青春壹個敷衍的年華 提交于 2019-12-04 00:14:46
问题 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 Upper"),digits=3) Problem when I output the table, columns are not centered. Actually, for some tables they are right aligned for others - left aligned, which seems rather random to me. Question How can I control the alignment of columns with R

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

how do you change the color of the cell in kable output table in knitr

巧了我就是萌 提交于 2019-12-01 10:36:39
I need to color the cell if the value of the cell is greater than 80. For example, given this data frame called df: dput(df) structure(list(Server = structure(1:2, .Label = c("Server1", "Server2"), class = "factor"), CPU = c(79.17, 93), UsedMemPercent = c(16.66, 18.95)), .Names = c("Server", "CPU", "UsedMemPercent"), row.names = c(NA, -2L), class = "data.frame") df[2,2] should be in red color. I was able to change the color of the text by something like this using xtable: df[, 2] = ifelse(df[, 2] > 80, paste("\\color{red}{", round(df[, 2], 2), "}"), round(df[, 2], 2)) If I do this and print

how do you change the color of the cell in kable output table in knitr

╄→尐↘猪︶ㄣ 提交于 2019-12-01 09:11:25
问题 I need to color the cell if the value of the cell is greater than 80. For example, given this data frame called df: dput(df) structure(list(Server = structure(1:2, .Label = c("Server1", "Server2"), class = "factor"), CPU = c(79.17, 93), UsedMemPercent = c(16.66, 18.95)), .Names = c("Server", "CPU", "UsedMemPercent"), row.names = c(NA, -2L), class = "data.frame") df[2,2] should be in red color. I was able to change the color of the text by something like this using xtable: df[, 2] = ifelse(df[

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