r-markdown

Extract only text from Rmd documents

泄露秘密 提交于 2019-12-31 00:58:15
问题 Not even sure if this is possible, but is there a way to extract only the raw text portion of the .Rmd file and discard any code? Or basically converting an .Rmd file into .txt file within R? I've tried the function readLines , but this makes a huuuuuge character with all kinds of (to me) useless meta-data. 回答1: You can knit document without evaluating and including code. Here's an example of dummy document foo.Rmd : # Header 1 foo ## Header 2 bar ## Header 22 foobar ```{r} 1 ``` text text

RMarkdown with knitr to HTML: How to hide bullets in TOC (table of contents)?

折月煮酒 提交于 2019-12-31 00:18:15
问题 How can I suppress the bullet points in front of the TOC items in the created HTML file? I want to see only the headline numbers... Example Test.Rmd file: --- title: "Untitled" author: "Author" date: "01/25/2015" output: html_document: number_sections: true toc: yes toc_depth: 3 --- *Content* # Headline 1 ## Sub headline 1.1 ## Sub headline 1.2 ### Sub sub headline 1.2.1 # Headline 2 The TOC of the resulting HTML document will look like this (with the unwanted bullet points - here indicated

How to write (bullet) lists in a table using rmarkdown and pandoc

你离开我真会死。 提交于 2019-12-30 10:49:09
问题 I am looking to create a table in a PDF document using rmarkdown , knitr and pander . The table should be nearly identical to Table 1 shown below, except the asterisks should be bullets. Is this at all possible using only the R libraries listed above? Here is my code to produce the PDF document (and thus the table above): --- title: "xxx" author: "xxx" date: "xxx" output: word_document: default pdf_document: fig_height: 4 fig_width: 10 highlight: tango geometry: margin=3cm --- ```{r global

Is there any way to show a wordcloud2 in Rmarkdown as a PDF or Word file?

别等时光非礼了梦想. 提交于 2019-12-30 07:22:13
问题 I'm trying to show a wordcloud2 wordcloud, but it only works in an html-knitted Rmd file. This works: --- title: "Untitled" output: html_document --- ```{r wordcloud} library(wordcloud2) wordcloud2(demoFreq) ``` But this does not: --- title: "Untitled" output: pdf_document --- ```{r wordcloud} library(wordcloud2) wordcloud2(demoFreq) ``` It will knit with always_allow_html: yes in the YAML, but the wordcloud doesn't show up: --- title: "Untitled" output: pdf_document always_allow_html: yes --

Plot several pictures with different size in a “for” loop

送分小仙女□ 提交于 2019-12-30 07:10:08
问题 I am new to knitr and markdown and this is my first question asked. Maybe this question has a simple answer that I just can't find. I have a for-loop, which creates 3 ggplots. The loop runs 300 to 400 times depending on the data input. I want to define the size of these 3 pictures as: 1st picture: width = 7, height = 3 2nd picture: width = 7, height = 3 3nd picture: width = 7, height = 12 So far I am using the following code: ```{r calc, echo=FALSE, warning=FALSE, message=FALSE, results='asis

knitr: can I cite an article in a figure caption using the fig.cap chunk option?

末鹿安然 提交于 2019-12-30 03:17:39
问题 I'd like to cite an article in my figure caption. I've tried using the Rmarkdown/pandoc [@citekey] and the latex \\citep{citekey} forms in the fig.cap chunk option without any luck. Here is a reproducible example: --- output: rmarkdown::tufte_handout references: - id: Nobody06 title: 'My Article' author: - family: Nobody given: Jr issued: year: 2006 --- Some text [@Nobody06]. ```{r figure, fig.cap="A figure [@Nobody06]"} library(ggplot2) qplot(1:10, rnorm(10)) ``` # References This produces

Highlighting bash code with knitr / rmarkdown

蓝咒 提交于 2019-12-30 03:13:49
问题 I'm trying to generate an HTML report using RStudio, R Markdown and knitr. In the report I would like to display some bash code. I do not want to run the code but I would like it to be highlighted. It has been mentioned in another question but the suggestion there doesn't work for me. Here's what I've tried so far: --- title: "bash highlighting?" output: html_document --- ```{r, engine = 'bash', eval = FALSE} for foo in (ls bar) do echo $foo done ``` ```{bash, eval = FALSE} for foo in (ls bar

Including a 3D interactive figure in html and static in word/pdf using knitr and rgl

限于喜欢 提交于 2019-12-30 00:46:07
问题 Following this question (including a interactive 3D figure with knitr) and this example by Yihui (https://dl.dropboxusercontent.com/u/15335397/misc/webgl-rmd.html), I can include a 3D interactive figure in html output using knitr and Rmarkdown. But I would like to include a static figure in word/pdf output. Is it possible to do this? Thanks for any suggestion. My sessionInfo > sessionInfo() R version 3.1.1 (2014-07-10) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English

Hiding the R code in Rmarkdown/knit and just showing the results

半腔热情 提交于 2019-12-29 11:32:08
问题 In my R Markdown documents, I sometimes want to just generate a report without showing the actual code (specially when I send it to my boss). How can I hide the R code and just show the graph and results? For example: --- output: html_document --- ```{r fig.width=16, fig.height=6} plot(cars) ``` This shows both the commands and the plot. How can I remove the commands from my HTML report? 回答1: Sure, just do ```{r someVar, echo=FALSE} someVariable ``` to show some (previously computed) variable

Error in YAML with R Markdown

三世轮回 提交于 2019-12-29 09:00:39
问题 I have the following R Markdown script called test.Rmd : --- params: results: value: !r mtcars --- ```{r setup, echo=FALSE, include=FALSE} df <- params$results knitr::kable(df) ``` When I run the following in OpenCPU: library(rmarkdown) library(knitr) rmarkdown::render("test.Rmd", output_format = "html_document") Error in yaml::yaml.load(yaml, handlers = knit_params_handlers(evaluate = evaluate), : unused argument (eval.expr = TRUE) I installed different versions of YAML and it didn't fix the