r-markdown

Using R markdown and knitr: Possible to get R objects interpreted in YAML

ε祈祈猫儿з 提交于 2019-12-06 02:41:38
I am using knitr , R markdown , and a custom LaTeX file to write a manuscript. The abstract is set as part of the YAML frontmatter. This works great, except that the results that I would like to include in the abstract are generated later in the document. Having the abstract in the YAML makes some sense to me and I would prefer to keep it this way. Any thoughts on a way to have the abstract take advantage of calculations that happen later in the document? A brief example: --- title: 'How do I interpret R objects in YAML that are created in the document?' author: Jeff Hollister output: pdf

R Markdown inline code not executed

拜拜、爱过 提交于 2019-12-06 02:13:28
问题 I have an inline code enclosed with single backticks on a single line. However, The cohort had r echo = FALSE load("../data/cohort.rda") nrow(cohort) subjects. is not executed and thus gives me this output in html and pdf: The cohort had r echo = FALSE load("../data/cohort.rda") nrow(cohort) subjects. I want this output: The cohort had 477 subjects. When I exclude echo=FALSE , I get this message: Quitting from lines 33-35 (Manuscript.Rmd) Error in base::parse(text = code, srcfile = NULL) : 1

How to keep R code and figure on the same page in RMarkdown when producing a pdf using knitr

核能气质少年 提交于 2019-12-06 02:10:39
问题 Is there a way in RMarkdown to force R code and the figure that it produces to appear on the same page please? I am using Knit pdf. For example, ```{r} ggplot(df, aes(x = x, y = y, col = sex_f)) + geom_point() + ggtitle("Data from Children") + labs(x = "Age (months)", y = "Height (cms)", col = "Child Gender") + geom_smooth(method = "lm", se = FALSE) + facet_grid(sex_f ~ town_f) ``` (which is not reproducible) produces code on one page and a plot on the next page. I have tried setting the

How to control plot height/size in interactive RMarkdown (with Shiny)

╄→尐↘猪︶ㄣ 提交于 2019-12-06 02:01:23
问题 I am using Shiny together with RMarkdown to produce an interactive document, as described here. Using the following code, I managed to plot an interactive map ```{r, echo=FALSE, warning=FALSE, message=FALSE} g2g14 <- readOGR("input//geodata", "g2g14") # no projection needs to be specified old_geodata <- g2g14@data inputPanel( selectInput("map.party", label = "Partei", choices = unique(long_data$Partei), selected = "FDP"), selectInput("map.year", label = "Wahljahr", choices = unique(format

In RMarkdown Word document, how to make table of contents appear later

China☆狼群 提交于 2019-12-06 01:45:13
When an RMarkdown document is knit to Word, the Table of Contents (if there is one) always appears at the beginning of the document. If I want to, say, make the Table of Contents appear on the second page of the document, how do I do so? If I was knitting to HTML I could use this method , but it doesn't seem to work for Word. Meaning, I create a Word template to be used in the reference_docx YAML argument and put the Table of Contents at the bottom of this template, but when I knit a report the Table of Contents appears at the front of the document. Preferably, I'd like to use a solution that

Change font size for individual text section in flexdashboard

﹥>﹥吖頭↗ 提交于 2019-12-06 01:35:36
问题 I'm using flexdashboard to create reports and I want to change a font size only for one part of the page. It feels to me that I can do it by adding CSS class, but I can't find how can I specify class name in R markdown code. Any ideas? 回答1: You can add CSS directly into your Rmarkdown document. For example, if you wanted to change the font of objects with class "chart-title" you could insert the following into your R markdown file: --- title: "Title" output: flexdashboard::flex_dashboard:

RMarkdown - Change Inline Code Color

早过忘川 提交于 2019-12-05 22:53:56
I am using inline code in RMarkdown and I would like all the text that is a result of inline code to be a different color in the document. In this example , I would like heat.colors to be red all over the document. Is there a way to do this? Or you can use text_spec in kableExtra . It literarily does the same thing but just a tiny bit more literal. See more here --- title: '' output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) library(kableExtra) ``` ## R Markdown This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF

How to type tilde in formulas in RMarkdown

谁说胖子不能爱 提交于 2019-12-05 22:51:38
问题 I am trying to type equations on RMarkdown to create a PDF and I want to use a tilde, how can I go about it. I am trying this but throws back a pandoc.exe: Error producing PDF from TeX source .... --- title: "See" date: "24 September 2016" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` follows a Bernouli distribution $$y_i \~ Bernouli(p_i)$$ 回答1: I believe if you do $$ \sim $$ This should produce the ~ you are attempting to place in your formula.

Converting Rmarkdown to PDF without RStudio

大城市里の小女人 提交于 2019-12-05 22:49:51
I would like to convert a *.Rmd to document to PDF without rstudio being available. Current approach Current approach follows the following steps: *.Rmd document is passed to knitr : knit(input = "report.Rmd")) Obtained md is converted via pandoc: # Convert pandoc --smart --to latex \ --latex-engine pdflatex \ -s report.md \ -o report.PDF Problems This results in the following problems, the top section of the Rmarkdown document: --- title: "Report Title" author: "Person" output: pdf_document classoption: landscape --- and shows as: all text is centered, whereas I would like for it to be left

How to print htmlwidgets to HTML result inside a function?

邮差的信 提交于 2019-12-05 22:03:52
--- title: "Untitled" output: html_document --- ```{r setup, include=FALSE} library(DT) xsx = function(){ print(getOption("viewer")) print(datatable(data.frame(d =1))) 1 } xsx() ``` Inside xsx() function, DT widgets will not be rendered in HTML result. How can I get widgets print inside a function? 来源: https://stackoverflow.com/questions/35567124/how-to-print-htmlwidgets-to-html-result-inside-a-function