r-markdown

What is this knitr magic that produces a plot by calling <<plot_this>>?

余生长醉 提交于 2019-12-22 08:04:05
问题 I am trying to work out how this report on a STAN model for the 2016 US presidential elections is generated using rmarkdown : https://raw.githubusercontent.com/pkremp/polls/master/report.Rmd I have looked at the source code available on github, which contains lines like: # Electoral College ```{r echo=FALSE, message=FALSE, fig.align='center'} <<plot_ev>> ``` The command <<plot_ev>> seems to generate plots from code in graphs.R: # Not accounting for the EV allocation rules of Nebraska and

How to run R Code in R Markdown file in SublimeREPL?

廉价感情. 提交于 2019-12-22 06:58:08
问题 I would like to test code parts in my R Markdown code without leaving Sublime Text. For instance: Multiplying the grades with two solves the unreliability problem: ```{r} chisq.test(2*grades) ``` In the above example, I would like to select the line that has the code "chisq.test(2*grades)", press my key combination, and have it ran in SublimeREPL as R code. However, when I try this, I get the following error from SublimeREPL: Cannot find REPL for 'HTML.markdown.rmarkdown' When I change the

knitr/markdown: how to render math equations in vignettes built by CRAN?

ぃ、小莉子 提交于 2019-12-22 06:37:12
问题 In a package, I have several vignettes that use mathematical notation, like: This vignette illustrates the ideas behind solving systems of linear equations of the form $\mathbf{A x = b}$ where - $\mathbf{A}$ is an $m \times n$ matrix of coefficients for $m$ equations in $n$ unknowns - $\mathbf{x}$ is an $n \times 1$ vector unknowns, $x_1, x_2, \dots x_n$ - $\mathbf{b}$ is an $m \times 1$ vector of constants, the "right-hand sides" of the equations When I compile the vignette using R Studio (

Rmarkdown Image Skips Ahead of Text

对着背影说爱祢 提交于 2019-12-22 06:31:13
问题 I am putting together an Rmarkdown PDF document with the following YAML settings: --- output: pdf_document: fig_caption: true fig_crop: true toc_depth: 3 header-includes: - \usepackage{hyperref} --- Within the body of the document I've inserted a few PNG images, using the following syntax Paragraph 1.......... ![Caption](path/image.png) Paragraph 2.... And when the document is rendered, the image appears as expected within the text, between Paragraph 1 and Paragraph 2 . However, I am getting

References page truncated in RMarkdown ioslides presentation

六眼飞鱼酱① 提交于 2019-12-22 05:01:14
问题 I prepare a ioslides presentation in RMarkdown via RStudio. As the presentation contains a lot of references they are truncated: With {.allowframebraks} there seems to be a quick solution for beamer presentations as this answer shows. Is there one for ioslides, too? 回答1: This isn't exactly what you're asking for, but it might be the best you can do. Insert the following inline CSS at the end of your document (i.e. just before where the references will be inserted), and instead of truncating

prevent knitr/Rmarkdown from interleaving chunk output with code

核能气质少年 提交于 2019-12-22 05:00:28
问题 When I use knitr to build an HTML document out of the following code: Chunk Output ======================================================== Outside a chunk. ```{r chunk1, results='asis'} cat('Inside a chunk\n\n') for (i in 1:3) { cat('* Inside loop #', i, '\n') } cat('Outside a loop, but still inside the first chunk') ``` Between chunks. ```{r chunk2, results='asis'} cat('Inside second chunk') ``` I get output where the code in chunk1 is interleaved with the output of the cat statements.

How to extend the renderTable width in Shiny flexdashboard

自古美人都是妖i 提交于 2019-12-22 04:54:10
问题 I have the following self containing Shiny-Flexdashboard: --- title: "FOO" runtime: shiny output: flexdashboard::flex_dashboard: vertical_layout: scroll orientation: rows theme: default --- ```{r setup, include=FALSE} library(flexdashboard) library(tidyverse) ``` Rows ------------------------------------- ### Statistical Test Summary ```{r stat_test_table} mainPanel( renderTable( { dat <- df <- structure(list(`Sample name` = structure(1:3, .Label = c("Sample1", "Sample2", "Sample3"), class =

Using R-markdown knitr hooks to custom format tables in HTML reports

杀马特。学长 韩版系。学妹 提交于 2019-12-22 04:38:07
问题 I am trying to set up a knitr::knit_hooks() to automatically format data frame output of an R-markdown chunk with kableExtra in my HTML report. I would like to not repeatedly add the following lines (or any lines) to the end of each chunk of tabulated data: head(iris) %>% kable("html") %>% kable_styling("hover", full_width = FALSE) I came up with one solution based on this answer that works by evaluating the chunk source (see my answer below that includes some issues that I have with this

Reduce file size of R Markdown HTML output

早过忘川 提交于 2019-12-22 04:31:38
问题 If I create a very basic R Markdown file with no images or code and knit this HTML, I end up with an outputted file size that is more than 700kb in size. Is there any way to reduce the HTML file size? Minimal Example: --- title: "Hello world!" output: html_document: default html_notebook: default --- Nothing else to say, really. The output file from html_document is 708.6 kb in size, while html_notebook is 765.7 kb. 回答1: The html_vignette format is perfect if you want a smaller file size. As

Reduce file size of R Markdown HTML output

白昼怎懂夜的黑 提交于 2019-12-22 04:31:21
问题 If I create a very basic R Markdown file with no images or code and knit this HTML, I end up with an outputted file size that is more than 700kb in size. Is there any way to reduce the HTML file size? Minimal Example: --- title: "Hello world!" output: html_document: default html_notebook: default --- Nothing else to say, really. The output file from html_document is 708.6 kb in size, while html_notebook is 765.7 kb. 回答1: The html_vignette format is perfect if you want a smaller file size. As