r-markdown

How to suppress automatic figure numbering in Rmarkdown / pandoc

允我心安 提交于 2019-12-03 13:15:10
问题 I have the following Rmarkdown (.Rmd) document where I call existing .png images and create a .pdf with captions. By default, pandoc? is automatically adding "Figure #." before the caption for each picture. I can see how this would be the normal thing to do, but in my case I would like to define this. I have found variations on this topic but don't seem to find a solution. Below is an example of how my .Rmd file looks: --- title: "TITLE" author: "ME" date: "`r Sys.Date()`" output: pdf

How to render HTML from RMarkdown without javascript in output

半城伤御伤魂 提交于 2019-12-03 13:04:34
Even the simplest rmarkdown document when rendered seems to create an html document that includes javascript. I am looking to create html that can be the body of an email. Is there a way to render markdown with no javascript in the resulting html? There is nothing special about the following, it is just a generic example: --- title: "Sample" author: "JKGrain" date: "March 31, 2015" output: html_document --- This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com

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

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 ,

Warning: Input string not available in this locale

 ̄綄美尐妖づ 提交于 2019-12-03 12:04:33
问题 Rstudio Version 1.0.136 R Version 3.3.2 It's strange that when I run code(it has Chinese comment in code)line by line in a .Rmd file with Rmarkdown,console will print a warning as follow: Warning message: In strsplit(code, "\n", fixed = TRUE) : input string 1 is invalid in this locale It's so annoying ,because every line it will appear. I has change default text encoding in RStudio's setting ,but neither UTF-8 nor BG2312 can prevent this warning messag appearing. Please notice that it just

changing font size in R DataTables (DT)

对着背影说爱祢 提交于 2019-12-03 12:03:37
问题 Have been trying to change the font size of all text in the tables generated by DT. However, I could only figure out how to change the size of the records using formatStyle(names(datCalc), fontSize = '12px') . The column headers and buttons have text of the same size. Using R Markdown in RStudio. 回答1: I think you almost got there. I solved it by explicitly telling DT::formatStyle() which columns I wanted. I first tried using the names() or colnames() approach, as you did. For some reason this

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

How to add multiple figures across multiple pages in a chunk using knitr and RMarkdown?

[亡魂溺海] 提交于 2019-12-03 11:25:37
I am using a for loop to create multiple big figures across multiple pages in one chunk with knitr and rmarkdown. It works fine for word and html outputs, but has one problem in pdf output. This is a minimal RMarkdown example to reproduce my problem. --- title: "Knitr test" date: "6 April 2015" output: pdf_document --- ```{r, echo=FALSE, fig.width=6.5,fig.height=10} library(ggplot2) for (i in seq(1, 4)){ p <- ggplot(cars, aes(speed, dist)) + geom_point() print(p) } ``` The generated pdf file looks like this. Two figures are printed in the page. If I change the fig.height, add a few section in