knitr

How to access MathJax extensions (like siunitx) from Rmarkdown via Pandoc & Knitr?

寵の児 提交于 2019-12-22 09:29:00
问题 Working with Rmarkdown in Rstudio , using pandoc and knitr , I am targetting PDF output via LaTeX and HTML output with MathJax . I would like to use some of the MathJax extensions that are available, to allow richer LaTeX for the PDF target. Specifically, I am trying to use the siunitx extension right now, although I am also interested in others (e.g. physics ). Using siunitx works fine with LaTeX for PDF output, but I've had a hard time getting it working with HTML output. Here an example

Change prompt character in knitr for JSS

杀马特。学长 韩版系。学妹 提交于 2019-12-22 09:23:55
问题 The Journal of Statistical Software style guide prescripes use of R> as prompt character. In Sweave this can be obtained through: options(prompt = "R> ", continue = "+ ", width = 70, useFancyQuotes = FALSE) Is it possible to set the prompt character in knitr as well? It seems like the prompt argument in chunks$set only allows for TRUE/FALSE . 回答1: Use this kind of setup in the .Rnw file: <<setup, include=FALSE, cache=FALSE>>= library(knitr) # set global chunk options opts_chunk$set(prompt

Add tex distribution to PATH for R studio

荒凉一梦 提交于 2019-12-22 08:42:04
问题 I have recently begun using knitr with Rstudio. I ran into the "No tex installation detected. Please install TeX before compiling." error in both my Ubuntu and windows OS's. After some research I was able to amend the issue in Ubuntu by adding the directory of my tex installation to PATH . I did this by including the following line in Renviron.site PATH=/usr/local/texlive/2013/bin:${PATH} However, the issue remains for my windows installation. I was unable to find the Renviron.site file, so I

Add tex distribution to PATH for R studio

五迷三道 提交于 2019-12-22 08:40:06
问题 I have recently begun using knitr with Rstudio. I ran into the "No tex installation detected. Please install TeX before compiling." error in both my Ubuntu and windows OS's. After some research I was able to amend the issue in Ubuntu by adding the directory of my tex installation to PATH . I did this by including the following line in Renviron.site PATH=/usr/local/texlive/2013/bin:${PATH} However, the issue remains for my windows installation. I was unable to find the Renviron.site file, so I

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 start page numbering in R Markdown from the second page?

你说的曾经没有我的故事 提交于 2019-12-22 06:41:10
问题 I was wondering if there is a way to start page numbering from the second page and/or print page numbers starting from second page in R Markdown when creating pdf output? This would be useful when adding a title page to the document. Thanks! 回答1: After receiving useful comments I solved issue by adding \pagenumbering{gobble} just before the title and \pagenumbering{arabic} after the title page as follows: \pagenumbering{gobble} \centerline{\includegraphics[height=2in]{youricon.png}} \large

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

Unable to get tikzDevice to work

送分小仙女□ 提交于 2019-12-22 05:41:31
问题 I have a problem with tikzDevice . I'm using the latest versions of R (with latest knitr and tikzDevice packages) and RStudio , updated TeX Live to 2015 binaries (and I think I have all the required packages). When I try to output graphics to tikzDevice , compilation hangs. Other graphics devices like PDF or CairoPNG work without a problem. As an example, I tried to compile a the simple code below from RStudio with XeLaTeX (set as the default LaTeX compiler in RStudio ), but it hangs forever

Unable to get tikzDevice to work

非 Y 不嫁゛ 提交于 2019-12-22 05:41:30
问题 I have a problem with tikzDevice . I'm using the latest versions of R (with latest knitr and tikzDevice packages) and RStudio , updated TeX Live to 2015 binaries (and I think I have all the required packages). When I try to output graphics to tikzDevice , compilation hangs. Other graphics devices like PDF or CairoPNG work without a problem. As an example, I tried to compile a the simple code below from RStudio with XeLaTeX (set as the default LaTeX compiler in RStudio ), but it hangs forever