knitr

Html output takes too long to load

吃可爱长大的小学妹 提交于 2020-05-09 07:53:29
问题 I have this html knit output from Rmarkdown but since it is pretty heavy (it is an online guide), the page takes too long to show up when opening the link. I tried to divide the rmd file into distinct rms sub files as below shown but I still can't get the result. Thank you title: "my_file" author: "me" date: "26/02/2020" output: html_document: toc: yes toc_depth: 3 toc_float: collapsed: yes smooth_scroll: yes word_document: default --- ```{r child = 'child0.Rmd'} ``` ```{r child = 'child1.Rmd

How can I knit a Rmarkdown file into a html file which embeds plots?

↘锁芯ラ 提交于 2020-04-30 09:25:38
问题 In a Rmd file, there are several places which generate plots, for example ```{r outliers} influencePlot (model1) ``` I knit the file into a html file and several image files under directory ./figure/ , by running in a R session > library(knitr) > knit("my.Rmd") and then running in a bash session $ pandoc my.md -f markdown -t html -s -o my.html but the html file doesn't embed the plots from the image files, for example: <img src="figure/outliers-1.png" alt="plot of chunk outliers" /> I was

How can I knit a Rmarkdown file into a html file which embeds plots?

一曲冷凌霜 提交于 2020-04-30 09:21:07
问题 In a Rmd file, there are several places which generate plots, for example ```{r outliers} influencePlot (model1) ``` I knit the file into a html file and several image files under directory ./figure/ , by running in a R session > library(knitr) > knit("my.Rmd") and then running in a bash session $ pandoc my.md -f markdown -t html -s -o my.html but the html file doesn't embed the plots from the image files, for example: <img src="figure/outliers-1.png" alt="plot of chunk outliers" /> I was

Rmarkdown / knitr subfigure different figure sizes

断了今生、忘了曾经 提交于 2020-04-16 04:04:14
问题 I am trying to achieve different heights and widths for subfigures in Rmarkdown. I was hoping that just providing fig.height and fig.width with a vector each would work, as this does seem to work for out.height and out.width --- title: "Untitled" output: pdf_document header-includes: - \usepackage{subfig} --- ```{r, echo = FALSE, fig.height = c(1,2,3), fig.width=c(1,1,1), fig.cap='Caption', fig.subcap=c('Subcaption 1', 'Subcaption 2', 'Subcaption 3')} library(ggplot2) df <- data.frame( x =

Rmarkdown / knitr subfigure different figure sizes

北战南征 提交于 2020-04-16 04:04:08
问题 I am trying to achieve different heights and widths for subfigures in Rmarkdown. I was hoping that just providing fig.height and fig.width with a vector each would work, as this does seem to work for out.height and out.width --- title: "Untitled" output: pdf_document header-includes: - \usepackage{subfig} --- ```{r, echo = FALSE, fig.height = c(1,2,3), fig.width=c(1,1,1), fig.cap='Caption', fig.subcap=c('Subcaption 1', 'Subcaption 2', 'Subcaption 3')} library(ggplot2) df <- data.frame( x =

How to reduce white space margins of world map

北城余情 提交于 2020-04-10 09:20:20
问题 library(maptools) data(wrld_simpl) plot(wrld_simpl) box() This gives me a world map and shows the plentiful white space top and bottom of the map. I would like this space to be gone as I need to print many (~60) maps. I am using knitr for the report in which the maps will be embedded. E.g. Here is some text. <<chunk.maps, eval = TRUE>>= library(maptools) plot(wrld_simpl) box() @ And some more text. But I don't think this is a knitr question. So: How can I get rid of the white space? How can I

How to reduce white space margins of world map

半世苍凉 提交于 2020-04-10 09:19:23
问题 library(maptools) data(wrld_simpl) plot(wrld_simpl) box() This gives me a world map and shows the plentiful white space top and bottom of the map. I would like this space to be gone as I need to print many (~60) maps. I am using knitr for the report in which the maps will be embedded. E.g. Here is some text. <<chunk.maps, eval = TRUE>>= library(maptools) plot(wrld_simpl) box() @ And some more text. But I don't think this is a knitr question. So: How can I get rid of the white space? How can I

Pandoc fails to render valid LaTeX macro definitions from markdown (and R markdown)

浪尽此生 提交于 2020-03-23 09:36:51
问题 In R, I have character objects that contain LaTeX macro definitions. The challenge is to use these objects in R Markdown documents, so that the macro definitions are rendered correctly when the .Rmd files are converted to LaTeX (and then to PDF). It is a challenge because Pandoc (v2.9.1 and 2.9.2) fails to render some macro-generating code correctly, even when that code is valid LaTeX. Here is a minimal example. First, consider this Rmd file: --- title: "Rendering LaTeX Macros from R Objects"

Pandoc fails to render valid LaTeX macro definitions from markdown (and R markdown)

荒凉一梦 提交于 2020-03-23 09:36:34
问题 In R, I have character objects that contain LaTeX macro definitions. The challenge is to use these objects in R Markdown documents, so that the macro definitions are rendered correctly when the .Rmd files are converted to LaTeX (and then to PDF). It is a challenge because Pandoc (v2.9.1 and 2.9.2) fails to render some macro-generating code correctly, even when that code is valid LaTeX. Here is a minimal example. First, consider this Rmd file: --- title: "Rendering LaTeX Macros from R Objects"

kable/kableExtra Add superscript to group labels in group_rows

百般思念 提交于 2020-03-03 11:33:08
问题 I have a table that I am creating for a pdf presentation using kable and kableExtra. I am wanting to group the rows and I need to use superscripts in the row group labels. I have tried several different things. Here is an example of some of the methods I have tried so far. library(kable) library(kableExtra) foo <- data.frame(a = 1:10, b = 11:20, c = 21:30) kable(foo, format = "latex", booktabs = T, row.names = FALSE, linesep = "", escape = FALSE) %>% kable_styling(latex_options = c("striped")