knitr

Suppress automatic table name and number in an .Rmd file using xtable or knitr::kable

匆匆过客 提交于 2019-12-21 04:22:07
问题 I'd like to name my tables from R scripts without the automatic Table 1:... prefix when using xtable() or knitr::kable() in an .Rmd file. Output is a pdf document. Here's a reproducible example from an .Rmd file: --- title: "Suppress automatic table name and number" output: pdf_document --- ```{r myirischunk, results = 'asis', tab.cap = NULL, echo = TRUE} library(xtable) print(knitr::kable(head(iris), caption = "I sure wish it would say Table 1.a")) print(knitr::kable(head(iris), caption =

knit HTML does not save html in vignettes/

浪子不回头ぞ 提交于 2019-12-21 04:11:36
问题 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

Beamer presentation RStudio change font size for chunk

偶尔善良 提交于 2019-12-21 04:08:34
问题 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? 回答1: One solution is using knitr hooks. A hook is code that will run before or after the

How to build a pdf vignette in R and RStudio

孤者浪人 提交于 2019-12-21 04:04:51
问题 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

How to write an if-then statement in LaTeX using the value of an R variable in knitr/Sweave

夙愿已清 提交于 2019-12-21 02:44:56
问题 I am currently using knitr along with R 3.0.2 and RStudio in order to produce a LaTeX report. My report is typed up as a .Rnw file, and compiled using the knit2pdf function. I would like to use an if-then formulation in LaTeX in order to create a separate section, but have the if-then condition use the value of a variable from R (let's call it CreateOptionalSection ). Is this possible? If so, how can I refer to the R variable in the .tex document? 回答1: Add \usepackage{comment} to the preamble

Inserting a page break within a code chunk in rmarkdown (converting to pdf)

大憨熊 提交于 2019-12-20 17:36:56
问题 I am using rmarkdown, pandoc and knitr to create a pdf including chunks of r code. Within a code chunk I have a for loop which prints a number of graphs and some statistical output. I would like to insert a page break into the loop (to appear in the pdf output). This page break would occur after each graph is printed, to ensure each graph is printed on one page and the statistical output on the next. I have been unable to find a way of including a page break in my r code chunk. I have tried

How to automatically create BibTex citations for R packages in knitr file?

寵の児 提交于 2019-12-20 17:34:32
问题 I am not sure whether this an R, LaTeX, or BibTex problem. I am trying to automatically generate a .bib file containing citations for R packages and then list them at the end. I am able to generate the BibTex file and I don't see anything wrong with the BibTex file, but the entries don't appear when I compile the PDF. I'm not sure if R is not producing a BibTex file correctly, if some LaTeX syntax is wrong, or if the BibTex file needs to be pre-compiled or whatever. I noticed that

Custom CSS with knitr and markdown in R

时光怂恿深爱的人放手 提交于 2019-12-20 12:37:05
问题 I found this great tutorial on how to modify the css formatting of a HTML report created with markdown and knitr in Rstudio. The post can be found here. I was hoping to build on this concept and mimic the layout of the page here by using the same css. I tried to simply copy/paste/combine the two css files I found when I viewed the page's source. Any help you can lend would be greatly appreciated! This is my first attempt and doing anything CSS. 回答1: This is the method provided by RStudio:

why does knitr caching fail for data.table `:=`?

笑着哭i 提交于 2019-12-20 10:36:23
问题 This is related in spirit to this question, but must be different in mechanism. If you try to cache a knitr chunk that contains a data.table := assignement then it acts as though that chunk has not been run, and later chunks do not see the affect of the := . Any idea why this is? How does knitr detect objects have updated, and what is data.table doing that confuses it? It appears you can work around this by doing DT = DT[, LHS:=RHS] . Example : ```{r} library(data.table) ``` Data.Table

Knitr: R code within LaTeX environment in a Markdown document

自古美人都是妖i 提交于 2019-12-20 10:24:38
问题 I have a document in Markdown, which incorporates R code via Knitr . For rendering equations I use LaTeX, simply writing its commands in the text. Say I have the following LaTeX code: \begin{displaymath} \mathbf{X} = \begin{bmatrix} 2 & 12\\ 3 & 17\\ 5 & 10\\ 7 & 18\\ 9 & 13\\ \end{bmatrix} \end{displaymath} Which renders me a nice mathematical matrix representation (in square brackets), when I convert everything to PDF (the full workflow is then: RMD -> knitr -> MD -> pandoc -> TeX -> pandoc