r-markdown

Input .tex in Rmarkdown

♀尐吖头ヾ 提交于 2019-12-10 21:05:52
问题 I'm using Rmarkdown/Bookdown to write a paper/PDF document, which is an amazing tool @Yihui, thanks! Now I'm trying to include a table I have already put in LaTeX into the document by reading in this external .tex file. However, when knitting in RStudio with a \include{some-file.tex} or input{some-file.tex} in the body of the .Rmd outside of a chunk a LaTeX Error: Can be used only in preamble. is produced and the process stopped. I haven't found a way how to directly input through knit or

Need the filename of the Rmd when knitr runs

浪尽此生 提交于 2019-12-10 20:34:05
问题 Recently I asked about having an r variable set to the name of an Rmd file when knitr runs. Need the filename of the Rnw when knitr runs in rStudio knitr:::.knitEnv$input.dir knitr:::knit_concord$get("infile") Is there a similar knitr::: object for the name of an Rmd file? 回答1: You can search through the parent.frames until you find the frame referring to where the body of the function knitr is being evaluated (and thus the input argument is defined. get(env = parent.frame(n = 8), 'input')

knitr/rmarkdown/Latex: How to cross-reference figures and tables in 2 different pdf files?

别等时光非礼了梦想. 提交于 2019-12-10 19:49:13
问题 I'm trying to write a scientific article and the associated supplementary materials entirely in RStudio with rmarkdown. It seems clear that book down is the way to go to cross-reference between files (https://stackoverflow.com/a/38884378/576684), but I also would like to be able to reference figures produced in one pdf in the other pdf. Although my latex has got quite rusty with time, I imagine it could be achieved as follows: compile the article tex and SuppMat tex a first time using

adding horizontal rule to html rmarkdown doc hides sections of text

戏子无情 提交于 2019-12-10 19:29:58
问题 I am making an Rmarkdown document that knits to an HTML page. Instead of separating some text sections with headers or bullets, I just want to draw horizontal lines between them. According to http://rmarkdown.rstudio.com/authoring_basics.html this would be called a "horizontal rule" and I can do that with three or more --- . However when I actually try to do this, various sections disappear from the html doc. Here is a very simple example of my code: --- title: "formatting issue" author: "rrr

Rmarkdown Beamer presentation, option clash clash for xcolor

梦想的初衷 提交于 2019-12-10 18:44:14
问题 I am trying to build a beamer presentation using rmarkdown. In my presentation I want to include tables using the kable , and kableExtra packages. I am having issues with this because one of the LaTex packages that kableExtra requires is already loaded by the beamer presentation with different options. This is the error message that I receive. ! LaTeX Error: Option clash for package xcolor. I have been searching for a fix for this but have not had any luck. I have found solutions on the LaTex

Building package source breaks down on vignette

Deadly 提交于 2019-12-10 18:22:48
问题 I have a package, lovingly documented with a html vignette using Rmarkdown and knitr. The package builds and works fine (on Windows). The vignette separately runs and renders with no problems. I can build a binary package with no problem. But when I try to build a source package, I consistently run into this error: Warning: running command '"C:/PROGRA~1/R/R-33~1.0/bin/x64/Rscript" --vanilla --default-packages= -e "tools::buildVignettes(dir = '.', tangle = TRUE)"' had status 1 Error: Command

RMarkdown html_output error

天大地大妈咪最大 提交于 2019-12-10 18:16:45
问题 I am trying to create a RMarkdown document with RStudio using shiny server . It works fine if the ouptut is pdf but if I want it as html I get this following error at the end of the process (in the RMarkdown console I can see it reached 100%). Error: unrecognized fields specified in html_dependency: attachment I have no idea why this error is happening. Can anyone help me with this? Thank you 回答1: This is caused by a recent update of the relevant rmarkdown package or related ones. Update

Cannot disable R markdown output from gridExtra (additional comment)

Deadly 提交于 2019-12-10 17:50:29
问题 In my r markdown report i use 2 chunks. First: ```{r, include = FALSE, echo=FALSE, results='asis'}``` Where i load all packages and do computation. And second {r, fig.margin = TRUE, fig.width=10, fig.height=4.5, echo=FALSE, results='asis', message=FALSE, warning = FALSE} Where i have for loop where I filter data I producent in first chunk, and make ggplots for each i. My problem is that, when i produce 2 plots in second chunk i combine them in one grid by grid.arrange, but there is additional

html_notebook ignores global chunk options

一笑奈何 提交于 2019-12-10 17:32:58
问题 Is there a way to use global chunk options in html_notebooks? This html_document only shows the title (as desired in this MWE): --- title: "Test" output: html_document --- ```{r setup, echo=FALSE} library(knitr) opts_chunk$set(echo=FALSE, results='hide', fig.keep='none') ``` ```{r} 1+1 plot(1:5, 1:5) ``` However, the very same document as an html_notebook shows all code chunks and output (the global chunk options are ignored): --- title: "Test" output: html_notebook --- ```{r setup, echo

inline dplyr in R Markdown

萝らか妹 提交于 2019-12-10 17:30:21
问题 I'm looking to inline some R code into an essay I'm writing. The following is fine: The quick brown fox jumped over \`r 2+2\` lazy dogs The quick brown fox jumped over 4 lazy dogs But when I try to combine dplyr with the following dataframe: structure(list(name = structure(c(2L, 1L, 3L), .Label = c("Cat", "Dog", "Horse"), class = "factor"), n = c(4L, 3L, 8L)), .Names = c("name", "n"), class = "data.frame", row.names = c(NA, -3L)) it breaks: The quick brown fox jumped over \`r as.numeric(temp