knitr

kable/kableExtra Add superscript to group labels in group_rows

折月煮酒 提交于 2020-03-03 11:32:02
问题 I have a table that I am creating for a pdf presentation using kable and kableExtra. I am wanting to group the rows and I need to use superscripts in the row group labels. I have tried several different things. Here is an example of some of the methods I have tried so far. library(kable) library(kableExtra) foo <- data.frame(a = 1:10, b = 11:20, c = 21:30) kable(foo, format = "latex", booktabs = T, row.names = FALSE, linesep = "", escape = FALSE) %>% kable_styling(latex_options = c("striped")

Insert GIF in pdf using rmarkdown

懵懂的女人 提交于 2020-03-03 07:50:43
问题 I am using rmarkdown to generate both HTML and pdf file. In my .Rmd file, I included a GIF like this: ![](www/script.gif) When I knit the to HTML it works fine. rmarkdown::render(documentation_file, encoding="UTF-8") However, when I try to knit to PDF using rmarkdown::render(documentation_file, rmarkdown::pdf_document(latex_engine = "xelatex"), encoding="UTF-8") I have the following problem: ! LaTeX Error: Unknown graphics extension: .gif. I do not mind to lose the animation of the gif, a

How to create table in rmarkdown using greek letters in column headers?

*爱你&永不变心* 提交于 2020-03-02 12:24:45
问题 I am trying to create a table in rmarkdown with kable and kableExtra and I want to put greek letters in the add_header_above function. kable(a, format = "latex", booktabs = T, longtable = T) %>% kable_styling() %>% add_header_above(c("n", "$\\alpha$", "Estimates for $\\alpha$" = 4, "Estimates for $\\beta$" = 4), align = "l", escape = F) I tried using escape = F like here, but it seems it doesn't work for greek letters. I want that style of table in my rmarkdown document with the greek letters

Is it possible to change the column width using kable without kableExtra?

烈酒焚心 提交于 2020-02-28 09:50:00
问题 Continue from this question. I want to modify the result's column width, but it can't be done without using the kableExtra . If I load the kableExtra package, the image will become text format. Here's the code: --- title: "Untitled" output: pdf_document: latex_engine: xelatex --- ```{r echo=FALSE, results='hide', warning=FALSE, message=FALSE} ## Load modules library(dplyr) library(tidyr) library(ggplot2) options(tinytex.verbose = TRUE) ## Create a local function to plot the z score

Is it possible to change the column width using kable without kableExtra?

爷,独闯天下 提交于 2020-02-28 09:47:10
问题 Continue from this question. I want to modify the result's column width, but it can't be done without using the kableExtra . If I load the kableExtra package, the image will become text format. Here's the code: --- title: "Untitled" output: pdf_document: latex_engine: xelatex --- ```{r echo=FALSE, results='hide', warning=FALSE, message=FALSE} ## Load modules library(dplyr) library(tidyr) library(ggplot2) options(tinytex.verbose = TRUE) ## Create a local function to plot the z score

Inline codes are not highlighted after using “knit html” function in Rstudio

旧巷老猫 提交于 2020-02-25 04:51:06
问题 I wrote an .Rmd file with some inline codes quoted by "`", and I used the knit html function in Rstudio to convert the .Rmd file to .html . However, the inline codes were not highlighted as on stackoverflow , and I took a look at the source codes of the .html file and found that the setting was like tt, code, pre { font-family: 'DejaVu Sans Mono', 'Droid Sans Mono', 'Lucida Console', Consolas, Monaco, monospace; } And I tried altering this block: tt, code, pre { font-family: 'DejaVu Sans Mono

Knit with custom parameters

孤者浪人 提交于 2020-02-07 02:01:36
问题 I can't get rmarkdown::render to take my params argument as in https://bookdown.org/yihui/rmarkdown/params-knit.html#knit-with-custom-parameters A minimal example of an Rmd called re.Rmd: --- title: "Untitled" output: pdf_document: template: def.tex params: title: "different" --- I changed the default pandoc latex template: pandoc -D latex > def.tex $if(title)$ \title{$title$$if(thanks)$\thanks{$thanks$}$endif$} $endif$ to $if(params.title)$ \title{$params.title$$if(thanks)$\thanks{$thanks$}

Formatting tables in R Markdown to export to MS Word document

半城伤御伤魂 提交于 2020-02-05 13:59:30
问题 I've started using expss in R Markdown for generating tables with the help of Knitr. I would like to automate the tables and analysis for a report I need to prepare in Microsoft Word format. When knitting to HTML, the tables look wonderful. The tables in Word are displayed as rows of plain text and does not resemble a table. Does expss support exports of tables to Word? Are there instructions on how to do it? Tables generated with kable and dplyr display correctly in Word. However, I'm

How can I force knitr to input a tikzpicture directly?

不羁的心 提交于 2020-02-04 04:46:46
问题 My aim is to produce a document by mixing hand-written .tex files and .tex files generated from an Rmarkdown file using knitr with figures rendered as tikzpicture. How do I achieve the generated .tex file to simply contain \begin{figure} \input{unnamed-chunk-1-1.tex} \end{figure} I am struggling with tikz as device. I tried the tikzDevice library as well as knitr::opts_chunk$set(dev="tikz") I managed to create a .tex file with a tikzpicture environment for every chunk. Unfortunately knitr

How can I force knitr to input a tikzpicture directly?

旧街凉风 提交于 2020-02-04 04:46:14
问题 My aim is to produce a document by mixing hand-written .tex files and .tex files generated from an Rmarkdown file using knitr with figures rendered as tikzpicture. How do I achieve the generated .tex file to simply contain \begin{figure} \input{unnamed-chunk-1-1.tex} \end{figure} I am struggling with tikz as device. I tried the tikzDevice library as well as knitr::opts_chunk$set(dev="tikz") I managed to create a .tex file with a tikzpicture environment for every chunk. Unfortunately knitr