knitr

knit HTML does not save html in vignettes/

僤鯓⒐⒋嵵緔 提交于 2019-12-03 13:31:37
So I have a vignette, vignettes/test-vignette3.Rmd : --- title: "Sample Document" output: html_document: highlight: kate theme: spacelab toc: yes pdf_document: toc: yes --- Header ========= When I hit the knit HTML button, I get the following: processing file: test-vignette3.Rmd output file: test-vignette3.knit.md Output created: /tmp/RtmpKVpegL/preview-5ef42271c0d5.dir/test-vignette3.html However, if I copy this file to inst/doc and hit the knit HTML button, I get: processing file: test-vignette3.Rmd output file: test-vignette3.knit.md Output created: test-vignette3.html My questions are: How

How to install the knitr-module in Lyx 2.0.3?

守給你的承諾、 提交于 2019-12-03 13:13:26
问题 I just installed Lyx 2.0.3 on my iMac and MacBook Air. When trying to open a *.lyx document on the iMac I get the following error-message: "The module knitr has been requested by this document but has not been found in the list of available modules. If you recently installed it, you probably need to reconfigure LyX." On the MacBook Air everything runs fine without any errors. Any ideas how to install the knitr-module manually? Thanks 回答1: The only requirement of the knitr module in LyX is R:

Conditional formatting tables in RMarkdown documents

前提是你 提交于 2019-12-03 12:55:38
问题 As an example, I might want to use the following rule to color the cells: (edited to un-trivialize) Blue if > 4 No fill if <= 4 and >= 3.5 Yellow if >= 3 and < 3.5 Orange if < 3 Create tables with conditional formatting with RMarkdown + knitr doesn't help me because I don't just want to highlight cells satisfying one set of criteria. Example rmd: --- title: "Untitled" output: html_document --- ```{r, message = FALSE, results = "asis"} library(knitr) library(dplyr) head(iris) %>% kable ``` I

R markdown PDF: Temporarily hide spoiler code for quiz takers

余生颓废 提交于 2019-12-03 12:45:13
I am using R markdown to create a PDF R course. I want to insert a quiz like the following: --- output: pdf_document --- What is the class of the following R object? 1. `pi` ```{r} class(pi) ``` Which, as expected, creates a PDF with this content: However, I would like the reader to not have such an easy access to the answer. These are the ideas I've had so far to achieve this: Paint the answer and code white, so the reader would have to select the text to see the answer; Include a tooltip that would work on mouse over question. Flush the answer to the end of the document; Setting the answer

knitr templates and child documents in a loop

一世执手 提交于 2019-12-03 12:37:09
Before Christmas I previously asked single style sheet across multiple knitr documents . I now know that the key search term I was missing is "child document". I have created a minimal markdown example but I am getting headers in the created document that are part of the knitting process. I am using RStudio to process it. I have seen many similar questions, but none of the answers work. I have tried various combinations of the chunk parameters and so far to no avail. Question: How do I get rid of the header from the final knitted document? # Master document ```{r master1, comment='', echo

How to build a pdf vignette in R and RStudio

六月ゝ 毕业季﹏ 提交于 2019-12-03 12:32:17
I am new to writing R packages. I'm trying to learn how to make a vignette for my package. I have created a vignettes folder with a file "getting-started.Rmd" --- title: "WaterML Tutorial" author: "Jiri Kadlec" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Introduction to the WaterML R package} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ## Quick Start This simple example shows how to get started with the <my R package>. To build the vignette I use the command: devtools::build_vignettes() Then I run Rcmd.exe INSTALL my_package ,

knit_child in a Rmd file is printing unwanted output

£可爱£侵袭症+ 提交于 2019-12-03 12:28:56
I had succesfully used knit_child for generating pdf files, following the code of http://yihui.name/knitr/demo/child/ , but when I try to use that example in a .Rmd file: ```{r, results='asis', echo=FALSE, message=FALSE} out = NULL for (p in c("p1","p2","p3","p4","p5","p6","p7","p8","p9","p10")) { out = c(out, knit_child('quick_variable.Rmd')) cat(out) } ``` (I modify the original code, for work in Rmd ). I have two problems, the first one: | | | 0% | |... | 5% ordinary text without R code | |....... | 11% label: unnamed-chunk-4 (with options) List of 1 $ echo: logi FALSE | |.......... | 16%

Beamer presentation RStudio change font size for chunk

为君一笑 提交于 2019-12-03 12:27:53
I am using Knit PDF to compile a beamer presentation in RStudio. --- title: "A.P. Statistics" author: "Notes for Chapter 3.Rmd" date: "Monday, October 13, 2014" output: beamer_presentation --- ## Computer Output ```{r} summary(lm(cars$dist~cars$speed)) ``` How can I change the font size (just for this one chunk, leaving other chunks the same font size) so that the output of this command fits on one slide? One solution is using knitr hooks . A hook is code that will run before or after the chunk code is executed. You could use it to insert a LaTeX fontsize command in the file. ```{r echo=FALSE}

Create appendix with R-code in rmarkdown/knitr

六眼飞鱼酱① 提交于 2019-12-03 12:03:24
问题 Is it possible to get all of the code in a appendix. Say I have two chunks in a document and then some text. ```{r, echo=TRUE} x <- 4+5 x ``` Above is X output. ```{r, echo=TRUE} y <- 22+325 y ``` Above is Y output. And then I want all of the code in a appendix but shown as if I put eval=FALSE in the chunk. Something like this ```{r, SHOW_ALL_CODE=TRUE} ``` Expected output: Chunk_1 y <- 22+325 y Chunk_2 x <- 4+5 x 回答1: knitr::purl() can extract all R code from a markdown file into an R script

Poor resolution in knitr using Rmd

帅比萌擦擦* 提交于 2019-12-03 11:37:40
问题 I have a .Rmd file and I am trying to create a .docx file via the function pandoc. I want to have a figure with final resolution of 504x504 pixels (i.e., 7x7inch with 72dpi). Unfortunately, the default 72 dpi is too poor in quality, and I would like to increase it to, say, 150 dpi without altering the final resolution (so it will already have the correct size within the .docx file). If I keep options fig.width and fig.height=7 and set dpi=150, I get the quality I want but the final resolution