knitr

How to number table with chapter number

家住魔仙堡 提交于 2021-02-07 20:40:29
问题 I inclue and cross-referencing a table in a Rmd file, and I want to add chapter number with the table title and referencing number, like "TABLE 1.1 test", but not "TABLE 1 test". I render the file using bookdown::word_document2. Here is a minimal example: --- title: test output: bookdown::word_document2: fig_caption: yes toc: yes --- ```{r} library(knitr) ``` # Heading 1 I'm cross-referencing a table table:\@ref(tab:test). ```{r test} test <- data.frame(a = 1:6, b = 2:7) kable(test, caption =

ggplot2: Exclude legend from aspect ratio

独自空忆成欢 提交于 2021-02-07 19:18:38
问题 I use ggplot2 and knitr to publish scatterplots with a right-hand-side legend. The legend is included in the aspect ratio and therefore breaks the "squareness" of the plots, as shown in the default themes. When the legend text becomes a bit longer than "a" and "b", the graphs become "long rectangles" instead of "squares". I would like to keep the graphs "squared", and so would like to exclude the legend from the aspect ratio on my ggplot2 graphs. My .Rprofile has the following information to

ggplot2: Exclude legend from aspect ratio

无人久伴 提交于 2021-02-07 19:17:57
问题 I use ggplot2 and knitr to publish scatterplots with a right-hand-side legend. The legend is included in the aspect ratio and therefore breaks the "squareness" of the plots, as shown in the default themes. When the legend text becomes a bit longer than "a" and "b", the graphs become "long rectangles" instead of "squares". I would like to keep the graphs "squared", and so would like to exclude the legend from the aspect ratio on my ggplot2 graphs. My .Rprofile has the following information to

Level 4 Heading issue in R Markdown

我的梦境 提交于 2021-02-07 14:20:56
问题 When I use #### for a level 4 heading, the output in pdf(latex) does not leave a line space before the paragraph begins. For example, #### Heading 4 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. Output only in pdf(latex) looks like this Heading 4 Lorem Ipsum is simply dummy text of the printing

Use `rmarkdown::render` in a restricted environment

…衆ロ難τιáo~ 提交于 2021-02-06 15:52:50
问题 I have the following Rmd file I called test.Rmd : --- title: "test" output: html_document --- ```{r} print(y) ``` ```{r} x <- "don't you ignore me!" print(x) ``` I want to call render the following way: render('test.Rmd', output_format = "html_document", output_file = 'test.html', envir = list(y="hello")) but it fails: processing file: test.Rmd |................ | 25% ordinary text without R code |................................ | 50% label: unnamed-chunk-1 |.................................

Use `rmarkdown::render` in a restricted environment

冷暖自知 提交于 2021-02-06 15:52:10
问题 I have the following Rmd file I called test.Rmd : --- title: "test" output: html_document --- ```{r} print(y) ``` ```{r} x <- "don't you ignore me!" print(x) ``` I want to call render the following way: render('test.Rmd', output_format = "html_document", output_file = 'test.html', envir = list(y="hello")) but it fails: processing file: test.Rmd |................ | 25% ordinary text without R code |................................ | 50% label: unnamed-chunk-1 |.................................

How to include all chapters in TOC in different html pages

↘锁芯ラ 提交于 2021-02-05 10:00:13
问题 I have a rmarkdown file which I need to knitr to get an html output composed of three different pages. Each page has some chapters (1 chapter in the first, 4 in the second page and 4 in the third). I need to repeat the full TOC ( with all chapters within ) in each page. With the code I have each TOC is split and refers to chapters of the single page only. I copied following code at the beginning of each page. I am very new to this thank you so much. --- title: "page" author: "me" date: "26/02

How to include all chapters in TOC in different html pages

梦想的初衷 提交于 2021-02-05 10:00:10
问题 I have a rmarkdown file which I need to knitr to get an html output composed of three different pages. Each page has some chapters (1 chapter in the first, 4 in the second page and 4 in the third). I need to repeat the full TOC ( with all chapters within ) in each page. With the code I have each TOC is split and refers to chapters of the single page only. I copied following code at the beginning of each page. I am very new to this thank you so much. --- title: "page" author: "me" date: "26/02

pandoc and rmarkdown: Can't fetch an image one level above a rmarkdown document

本小妞迷上赌 提交于 2021-02-05 04:58:16
问题 I am just starting to use rmarkdown, pandoc and knitr. I am having a great deal of difficult trying to get pandoc to fetch an image that is one level above an rmarkdown document. For example, consider our project directory is ~/test, the following rmarkdown is located at ~/test/scripts: --- title: "test" --- ```{r global_options, include=FALSE} library('knitr') opts_knit$set(root.dir = '~/test') ``` ![test](figures/test.svg) I then run the command Rscript -e "rmarkdown::render('scripts/test

Compact table in html document rmarkdown with kableExtra?

偶尔善良 提交于 2021-01-29 20:17:22
问题 I'm trying to make a 'compact' table in an RMarkdown I've tried a few things, mostly variations on setting a custom css class and providing the custom css class to a code chunk I've tried a lot of variations, all of which I can see flow through to the source code (accessed via knitting the html document, opening in chrome, and cmd + opt + u to view source and inspecting the source) However, I can't work out what's necessary to simply make rows thinner (I believe that's simply reducing cell