r-markdown

How can we pass pandoc_args to yaml header in rmarkdown?

允我心安 提交于 2019-12-18 12:29:19
问题 I'm using rmarkdown to produce a word (.docx) report. I would like to change the header of the toc. This seems possible as pandoc_args can be passed as options in the yaml header in the case of a doc file (1). But I'm not doing it right. Could anyone provide a working example ? (1) pandoc.args is included in the rmarkdown possible options and in the pandoc manual, there is a toc-title option --- title: "yaml header" author: "cedric" output: word_document: toc: true pandoc_args: toc-title=

Pass Parameters from Command line into R markdown document

与世无争的帅哥 提交于 2019-12-18 12:28:12
问题 I'm running a markdown report from command line via: R -e "rmarkdown::render('ReportUSV1.Rmd')" This report was done in R studio and the top looks like --- title: "My Title" author: "My Name" date: "July 14, 2015" output: html_document: css: ./css/customStyles.css --- ```{r, echo=FALSE, message=FALSE} load(path\to\my\data) ``` What I want is to be able to pass in the title along with a file path into the shell command so that it generates me the raw report and the result is a different

How make 2 column layout in R markdown when rendering pdf?

守給你的承諾、 提交于 2019-12-18 12:18:59
问题 When rendering html documents with rmarkdown there are ways to make a two columns layout, e.g. here Is there an easy way to render a pdf document with two column layout? Is there an example code somewhere? 回答1: You can use the article option twocolumn to format the whole document in two columns. Add this to your yaml front matter: --- output: pdf_document: pandoc_args: [ "-V", "classoption=twocolumn" ] --- 回答2: More succinctly: --- output: pdf_document: classoption: twocolumn --- 回答3:

Adding custom CSS tags to an RMarkdown html document

与世无争的帅哥 提交于 2019-12-18 12:15:40
问题 I have an RMarkdown document outputting to HTML of the same form as the below example. What do I add where to apply unique CSS ids or classes to each plot output? --- title: "RMarkdown" author: "Me" date: "Friday, March 27, 2015" output: html_document: theme: null css: style.css --- ```{r plot1, echo=FALSE, warning=FALSE, message=FALSE} library(ggplot2) x <- ggplot(some_r_code) print(x) ``` ```{r plot2, echo=FALSE, warning=FALSE, message=FALSE} y <- ggplot(some_more_r_code) print(y) ``` I've

R markdown: Accessing variable from code chunk (variable scope) [duplicate]

岁酱吖の 提交于 2019-12-18 11:15:23
问题 This question already has answers here : Is there an R Markdown equivalent to \Sexpr{} in Sweave? (2 answers) Closed last year . In R markdown (knitr package), can I access a variable within the body of the document that was calculated in a code chunk? 回答1: Yes. You can simply call any previously evaluated variable inline. e.g. If you had previously created a data.frame in a chunk with df <- data.frame(x=1:10) `r max(df$x)` Should produce 10 回答2: I would like to add that this is not the case

Producing subscripts in R markdown

╄→гoц情女王★ 提交于 2019-12-18 10:46:09
问题 I'm aware that R markdown can produce superscripts: text^superscript But is it possible to produce proper subscripts? Or is the only way to do so to cheat and use LaTeX math mode: $\sf{text_{subscript}}$ The intended final output is HTML. 回答1: Since you mention Pandoc in your comments, maybe it's not cheating to depend on Pandoc's extensions for subscript and superscript . From here, we can create a minimal example Rmd file: Testing Subscript and Superscript ==================================

R Shiny includeHTML missing htmlWidgets in a reactive context

不羁岁月 提交于 2019-12-18 09:26:56
问题 UPDATE: I posted a related question here I need to include an html file in shiny using includeHTML. The file is generated by rmarkdown, and has a large number of htmlWidgets. Shiny is showing the html file, but the htmlWidgests are missing. The problem occurs only when includeHTML is in server.R, but works ok if includeHTLM is in ui.R. I need to update file.html so includeHTML must be used in a reactive context. The file.rmd is somthing like this --- title: "test" author: "me" date: '`r Sys

RMarkdown: ! Package pdftex.def Error; online image not found?

邮差的信 提交于 2019-12-18 09:16:17
问题 I am running into a problem when trying to include a web-based image within a R Markdown PDF document. Minimal Example : --- title: "Random" output: pdf_document --- ![Benjamin Bannekat](https://octodex.github.com/images/bannekat.png) Knitting the above results in the error: ! Package pdftex.def Error: File `https://octodex.github.com/images/bannekat.pn g' not found. However, if I use the following code, the image shows up: --- title: "Random" output: html_document: default html_notebook:

Can R's htmltools::includeHTML not handle leaflet maps?

天涯浪子 提交于 2019-12-18 09:11:55
问题 I try to use the concept from here in an automated way, but maps are not displayed. The included html looks ok: Minimal reproducible example: For the generation of the html see below or. --- title: "Test" author: "SQC" date: "11 Juli 2019" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) library(leaflet) save_path <- paste0("C:/Temp/SO-question/") i <- 2 ``` # Title level 1 This works ```{r, echo = FALSE, results='asis'} htmltools::includeHTML(paste0

How to create R-markdown sections inside a R code chunk? With proper code display

筅森魡賤 提交于 2019-12-18 07:11:50
问题 I am currently writing on a report with rmarkdown and therefore I want to create sections inside a r code chunk. I figured out that this is possible with the help of cat() and results="asis" . My problem with this solution is, that my R code results and code isn't properly displayed as usual. For example --- title: "test" output: pdf_document --- ```{r, results='asis'} for (i in 1:10) { cat("\\section{Part:", i, "}") print(summary(lm(data=X, X1~X2)) $\alpha = `r X[1,i]`$ } ``` pretty much