knitr

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

Table of content in beamer generated with R markdown/knitr

泄露秘密 提交于 2019-12-29 08:53:06
问题 In line with this question, I have problems generating table of contents with a beamer class document, which I have made in RStudio with R markdown and knitr. My YAML header looks like this: --- params: x: !r x author: "Author" date: "Januar 2016" graphics: yes fontsize: 10pt output: beamer_presentation: includes: in_header: in_header.tex keep_tex: yes latex_engine: xelatex slide_level: 1 template: body.tex toc: true classoption: aspectratio=169 --- I use the default beamer template in body

Use hooks to format table in output

╄→гoц情女王★ 提交于 2019-12-29 08:32:31
问题 Using knitr and R Markdown, I can produce a tabularised output from a matrix using the following command: ```{r results='asis'} kable(head(x)) ``` However, I’m searching for a way to make the kable code implicit since I don’t want to clutter the echoed code with it. Essentially, I want this: ```{r table=TRUE} head(x) ``` … to yield a formatted tabular (rather than the normal output='markdown' ) output. I actually thought this must be pretty straightforward since it’s a pretty obvious

Use hooks to format table in output

痴心易碎 提交于 2019-12-29 08:31:05
问题 Using knitr and R Markdown, I can produce a tabularised output from a matrix using the following command: ```{r results='asis'} kable(head(x)) ``` However, I’m searching for a way to make the kable code implicit since I don’t want to clutter the echoed code with it. Essentially, I want this: ```{r table=TRUE} head(x) ``` … to yield a formatted tabular (rather than the normal output='markdown' ) output. I actually thought this must be pretty straightforward since it’s a pretty obvious

Dynamic number of calls to a chunk with knitr

穿精又带淫゛_ 提交于 2019-12-29 07:43:13
问题 I have such a list: > lSlopes $A Estimate 2.5 % 97.5 % 1 2.12 -0.56 4.80 $B Estimate 2.5 % 97.5 % 1 2.21 -0.68 5.10 $C Estimate 2.5 % 97.5 % 1 2.22 -2.21 6.65 It has three elements but its length can change (according to the data not shown here). I want to display each element in a chunk. My first idea was to write a chunk containing a loop calling knit_child() at each step, but I don't know how to get the correct rendering with knit_child() . I have find the following solution which works

Evaluate inline r code in rmarkdown figure caption

纵饮孤独 提交于 2019-12-29 06:13:44
问题 I am using RStudio and knitr to knit .Rmd to .docx I would like to include inline code in figure captions e.g. something like the following in the chunk options: fig.cap = "Graph of nrow(data) data points" However, knitr does not evaluate this code, instead just printing the unevaluated command. Is there a way to get knitr to evaluate r code in figure/table captions? 回答1: knitr evaluates chunk options as R code. Therefore, to include a variable value in a figure caption, just compose the

Figure sizes with pandoc conversion from markdown to docx

不打扰是莪最后的温柔 提交于 2019-12-29 03:36:12
问题 I type a report with Rmarkdown in Rstudio. When converting it in html with knitr, there is also a markdown file produced by knitr. I convert this file with pandoc as follows : pandoc -f markdown -t docx input.md -o output.docx The output.docx file is nice except for one problem: the sizes of the figures are altered, I need to manually resize the figures in Word. Is there something to do, maybe an option with pandoc , to get the right figures sizes ? 回答1: An easy way consists in including a

What is the knitr equivalent of `R CMD Sweave myfile.rnw`?

陌路散爱 提交于 2019-12-29 02:32:31
问题 What is the command-line knitr equivalent of R CMD Sweave myfile.rnw ? 回答1: The general solution (works regardless of the R version): Rscript -e "library(knitr); knit('myfile.Rmd')" Since R 3.1.0, R CMD Sweave has started to support non-Sweave documents (although the command name sounds a little odd), and the only thing you need to do is to specify a vignette engine in your document, e.g. %\VignetteEngine{knitr::knitr} To see the possible vignette engines in knitr , use library(knitr) library

LaTeX figure label from R plot using KnitR?

倾然丶 夕夏残阳落幕 提交于 2019-12-28 12:46:54
问题 I can't get R/KnitR to create the LaTeX \label{} statement for a figure. The manual seems to indicate that a \label{} statement will be created by concatenating the string in fig.lp ("fig:" by default) with the label for the R-code chunk. I haven't been able to get this to work, however. No \label{} statement is created for the first figure created by knitting the MWE below. The second figure has it's label added with a workaround that I just discovered, putting the R chunk in a figure