r-markdown

How can I incrementally build a plot in an ioslide presentation using Rmarkdown?

可紊 提交于 2020-05-27 05:04:05
问题 I'm trying to build a plot incrementally on one slide using Rmarkdown to create an ioslides (HTML) presentation. I've tried using {.build} but to no avail, and it seems there is no documentation on this in the Rmarkdown community. Does anyone know how to write this code in R? Here is a MWE where I try to build a plot in three steps, from a blank plot to a scatterplot to a lineplot, all in one slide where the plots unfold by clicking forward one at a time: --- title: "Untitled" author: "User"

rmarkdown error “attempt to use zero-length variable name”

喜你入骨 提交于 2020-05-26 10:38:32
问题 When i generate a new rmarkdown file (or open existing rmarkdown-files) and try to run a rmarkdown chunk, i get this error: "Error: attempt to use zero-length variable name". I have Win10 and did a fresh install of R and Rstudio yesterday. What did i miss? Where does this error come from? ```{r cars} summary(cars) ``` ```{r cars} Error: attempt to use zero-length variable name 回答1: Putting this as an answer for visibility: this happens if you try to run by selecting all in the Rmd and

For R Markdown, How do I display a matrix from R variable

喜夏-厌秋 提交于 2020-05-25 06:54:25
问题 I have a rmd document where I have the following ```{r code_block, echo=FALSE} A = matrix(c(1,3,0,1),2,2) B = matrix(c(5,3,1,4),2,2) ``` $$ \begin{bmatrix} 1 & 0 \\ 3 & 1 \\ \end{bmatrix} * \begin{bmatrix} 5 & 1 \\ 3 & 4 \\ \end{bmatrix} $$ Now I would like to instead of hard coding the LaTeX part manually, I could use the matrix from the variables A and B instead. How could this be done? Thanks. 回答1: Straightforwardly, you can write latex line. writeLines() or cat() would be helpful. You can

Relative image paths for Twitter cards in blogdown

好久不见. 提交于 2020-05-23 12:44:04
问题 I'm trying to set up a template for generating Twitter Cards in blogdown . It put the following in layouts/partials/twitter-card.html : <meta name="twitter:site" content="@myname"> <meta name="twitter:creator" content="@myname"> {{ if .IsPage }} <meta name="twitter:description" content="{{ .Summary }}" /> <meta name="twitter:title" content="{{ .Title }}" /> <meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:image" content="{{ .Params.image }}" /> {{ else }} <meta

Miktex did not succeed after I updated R to version 3.5.0

China☆狼群 提交于 2020-05-23 09:34:33
问题 After I updated R to version 3.5.0, I couldn't start my MikTex from Rstudio, --- output: pdf_document: latex_engine: xelatex includes: in_header: header.tex keep_tex: yes --- Above is the code I typed ahead of my Rmd, and after knitring, Sorry, but D:\miktex\miktex\bin\x64\xelatex.exe did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:/Users/DELL/AppData/Local/MiKTeX/2.9/miktex/log/xelatex.log Information showed in xelatex.log: 2018-04-29 10:06:17

Using bold text in a loop for a Word document in Rmarkdown

旧街凉风 提交于 2020-05-18 18:37:12
问题 I'm new to using Rmarkdown. I have a loop from which I extract a set of results for each iteration. This is fine. However, I am unable to get the text to print as bold. Here is some example code: ```{r echo=FALSE} x <- data.frame(var1 = c(1,0.99,0.98,0.97,0.95), var2 = c(1,0.995,0.99,0.98,0.97), var3 = c(1,0.98,0.96,0.94,0.90) ) year <- 1980:2010 # Do stuff across the loop: for(j in 1:nrow(x)){ temp_var1 <- constant1 * var1[j] * var2[j] * var3[j] temp_var2 <- constant2 * var1[j] * var2[j] *

Subfigures or Subcaptions with knitr that span more than one page?

好久不见. 提交于 2020-05-17 08:46:39
问题 Very similar to this post. However I have more plots than that fit on one page causing the remaining plots to be cut off after pressing Knit. Does any one know how to solve this by plotting the other plots on the next page? title: 'title' author: "--" date: "`r Sys.Date()`" output: pdf_document header-includes: - \usepackage{subfig} - \usepackage{float} ## To make the example more reproducible ## ```{r echo=FALSE, message=FALSE} knitr::opts_chunk$set(fig.width=6, fig.height=9, fig.show="hold"

Embed but don't run R scripts in Rmarkdown

旧街凉风 提交于 2020-05-17 07:06:40
问题 I am writing a paper in Rmarkdown about an ongoing project. I have my own .Rmd file where I am writing it. At the same time, I have several scripts in R stored in different files with the extension .R . In different parts of the paper I need to describe what it is in those R scripts, so that I need to embed the codes of the scripts in the Rmarkdown file without running it. To summarize: Folder 1 paper.Rmd script1.R script2.R I tried this chunk with no success: ```{r eval=F} source("script1.R"

How to change bibliography style in Rmarkdown?

依然范特西╮ 提交于 2020-05-17 06:29:06
问题 I am trying to change the style of my bibliography in Rmarkdown. I followed this solution but nothing happens in my case. This is my code: --- title: "Tilte" author: - name: Rollo99 abstract: | Abstract keywords: whatever date: "`r Sys.Date()`" citation_package: natbib bibliography: library.bib biblio-style: abbrvdin references: link-citations: yes linkcolor: blue output: rticles::elsevier_article: number_sections: yes header-includes: - \setcitestyle{numbers} - \usepackage{amsmath} -

How to include @font-face within style tag of RMarkdown?

血红的双手。 提交于 2020-05-17 05:46:32
问题 Is it possible to use the CSS @font-face to provide font files to an RMarkdown? e.g.: <style> @font-face { font-family: "Custom"; src: url(https://github.com/stevecondylios/fonts/raw/master/CircularStd-Book.ttf) format("truetype"); } body { font-family: "Custom", Verdana, Tahoma; } </style> Note that the exact same css code above (less the style tags) does work when it's stored in an external .css file locally and referenced in the Rmd's yaml with --- title: "My Rmarkdown doc" date: "28 April