r-markdown

HTML code inside of a R-markdown block for a single line

╄→尐↘猪︶ㄣ 提交于 2020-06-16 13:00:59
问题 I have an R-markdown document in a for loop (testing various kinds of models), and I would like to set them off with HTML Headers, as it is otherwise hard to find the models I am looking for. There is the "asis" option, but that turns off formatting for the entire block, which is not what I want. I have tried a few things I found here, but nothing really works. Here is my code: --- title: "Untitled" author: "Mike Wise - 25 Jul 2014" date: "November 2, 2015" output: html_document --- Test ```

R Markdown: place an Appendix after the “References” section?

南楼画角 提交于 2020-06-16 06:21:29
问题 I am writing a report with R Markdown in which I include references. The problem is that R markdown automatically places references at the end of the report. I would like to place an Appendix after the references, is there a way to do it? I saw that it is possible with a child document but I would like to have everything in a unique .Rmd file. Below is a reproducible example: --- title: author: date: abstract: output: pdf_document: template: NULL number_sections: true citation_package:

R Markdown: place an Appendix after the “References” section?

痴心易碎 提交于 2020-06-16 06:21:06
问题 I am writing a report with R Markdown in which I include references. The problem is that R markdown automatically places references at the end of the report. I would like to place an Appendix after the references, is there a way to do it? I saw that it is possible with a child document but I would like to have everything in a unique .Rmd file. Below is a reproducible example: --- title: author: date: abstract: output: pdf_document: template: NULL number_sections: true citation_package:

How to merge and print multiple code chunks in RMarkdown?

試著忘記壹切 提交于 2020-06-16 03:04:16
问题 My Rmarkdown document looks something like this. --- yaml metadata --- ```{r} x <- 10 ``` Some code explanation ```{r} y <- 10 ``` Some more code explanation ```{r} z <- x + y ``` The final output ``` # 10 ``` Since I am following the concepts of literate programming, how to print these multiple code chunks stitched together, so I can get the whole working code printed out as follows without the code explanation. Also, can I select specific code chunks and not all and print them out? x <- 10

How to show formatted R output with results='asis' in rmarkdown

 ̄綄美尐妖づ 提交于 2020-06-15 06:27:27
问题 Is there a way of showing formatter R output in rmarkdown/knitr when using results = 'asis'? An example would be the following function: myfun <- function() { cat("hello!\n") cat(c("one" = 1, "two" = 2)) } Then, this chunk will print the second cat on a new row: ```{r} myfun() ``` But this will ignore the formatting from myfun : ```{r, results = "asis"} myfun() ``` Is there a way of keeping results='asis' but at the same time keep the output of myfun formatted as intended? 回答1: You can use

Beamer Rmarkdown, changing slide count for backup slides

痴心易碎 提交于 2020-06-13 13:32:58
问题 I am trying to implement this question but in an Rmarkdown beamer presentation: https://tex.stackexchange.com/questions/70448/dont-count-backup-slides Can anyone help me out? When I try to put the TeX into the markdown, I get all kinds of errors, often: ! Missing \endgroup inserted. <inserted text> \endgroup l.437 \end{frame} pandoc: Error producing PDF Error: pandoc document conversion failed with error 43 Execution halted To give example code, I run this in the latex preamble: \usepackage

Reproducibility problems with Rmarkdown and Renv

旧街凉风 提交于 2020-06-13 08:05:53
问题 I recently noticed that the same R markdown document was generating different plots when being run in different conditions (eg. different projects). As a toy example, consider the following document: --- title: "Example" output: html_document --- ```{r plot, warning=FALSE, echo=FALSE} library("tidyverse") tibble(mu = c(-9.4, -9.3, -9.2, -9, -8.9, -8.8, -8.7, -8.5, -8.4, -8.3, 0), N = c(1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 3)) %>% ggplot() + geom_point(aes(x=mu, y=N)) + geom_bar(aes(x=mu, y=N), stat=

kableExtra: Vertical alignment not working in PDF output with many columns

南楼画角 提交于 2020-06-13 07:08:22
问题 The bounty expires in 2 days . Answers to this question are eligible for a +50 reputation bounty. mavericks wants to draw more attention to this question. I would like to align all columns in a kableExtra table to the top. The valign = "top" option does not seem to solve the issue here. Also, the third column is somehow dropped on top of the second for some reason, and citations are not working too. The MWE below is based on this related SO question, which only needs 2 columns: kable:

kableExtra: Vertical alignment not working in PDF output with many columns

扶醉桌前 提交于 2020-06-13 07:06:28
问题 The bounty expires in 2 days . Answers to this question are eligible for a +50 reputation bounty. mavericks wants to draw more attention to this question. I would like to align all columns in a kableExtra table to the top. The valign = "top" option does not seem to solve the issue here. Also, the third column is somehow dropped on top of the second for some reason, and citations are not working too. The MWE below is based on this related SO question, which only needs 2 columns: kable:

Increase line/row spacing with kableExtra

≡放荡痞女 提交于 2020-06-12 04:35:22
问题 Is there a way to increase the line spacing with kableExtra for a pdf output in r-markdown or bookdown? library(knitr) library(kableExtra) kable( head(iris, 5), caption = 'Iris Table', booktabs = TRUE) %>% kable_styling(latex_options = "striped") 回答1: You can just do it using the LaTeX command \arraystretch : --- output: pdf_document --- ```{r setup, include=FALSE} library(kableExtra) library(tidyverse) ``` \renewcommand{\arraystretch}{2} ```{r, echo=FALSE} library(knitr) library(kableExtra)