r-markdown

Markdown unnumbered section but needs anchor

£可爱£侵袭症+ 提交于 2021-02-20 18:59:40
问题 I am working with a Markdown document where I would like to have some sections not be numbered. But I also want to create anchors for these sections. Here is an example: # Appendix A: Methodology {-} {#methodology} I want to have Appendix A not be numbered but I still want to link to it using the anchor. Ideally, the solution would work for both LaTeX PDF and HTML. I have figured out how to turn off the numbered section thing for LaTeX but it's not working for HTML. 回答1: If you want to

Placing table next to plot in R Markdown (to pdf / latex)

霸气de小男生 提交于 2021-02-20 03:55:07
问题 Is it possible to place a table generated with the xtable (or alternatively the pander ) package and a generated plot side-by-side in R markdown knitting to pdf while the rest of the document is not in columns? The following simple example hopefully illustrates the idea: \begin{multicols}{2} ```{r} plot(cars) ``` ```{r, results='asis'} library('xtable') print(xtable(head(cars,5)), type = "latex") ``` \end{multicols} However, this does not produce the plot. I know that solutions exist using

How to set a theme when knitting RMarkdown to HTML?

北城以北 提交于 2021-02-19 03:50:06
问题 I have not been able to figure out how to set a knitr theme when converting RMarkdown to HTML. I have tried code such as > opts_knit$set(out.format = "html") > opts_chunk$set(highlight = TRUE) > knit_theme$set("olive") That does not affect the html output. I have tried this code before knitting the Rmd file as well as inside the first chunk. 回答1: Put a css file with the same name as your R file, but extension css, into the directory. Or see http://www.rstudio.com/ide/docs/authoring/markdown

R Markdown - Hyperlink outside Rmd file

一曲冷凌霜 提交于 2021-02-18 18:56:52
问题 I am wondering how we can define a hyperlink for R markdown outside Rmd file. Defining a hyperlink inside Rmd file is as easy as typing [hyperlink lable](actual link); but, if on the Rmd file, I am calling some other r-file (e.g., a function) that generates an address to a file, is there a way to transfer this information back to Rmd file to generate a hyperlink there? Please see example below for more clarification: Inside Rmd file: myFun( with some input) Inside myFun: myFun <- function(

Cite author only in RMarkdown / add possessive 's to in-text citation

蹲街弑〆低调 提交于 2021-02-18 17:15:13
问题 I'd like to cite an author in RMarkdown adding a possessive 's to his name. However, I cannot find a way to cite the author without the year of publication or to directly add a possessive 's . It should look like this: In Fenner's (2012) book ... Minimal Working Example (for a R Notebook): --- title: "R Notebook" output: html_notebook references: - id: fenner2012a title: One-click science marketing author: - family: Fenner given: Martin container-title: Nature Materials volume: 11 URL: 'http:

Change font size for all inline equations R markdown

六月ゝ 毕业季﹏ 提交于 2021-02-18 12:37:05
问题 I am creating a r-markdown file and using knitr to convert to HTML. When I inline an equation such as X_1,...,X_n \sim N(0,1) it gets converted to HTML output as this . The math text is oversized relative to the plain text font. I can correct this for a single equation with \small X_1,...,X_n \sim N(0,1) . However, I would prefer not to type \small hundreds of times throughout a document. Does anyone know how to correct this with a single settings change or modification so it's applied to all

Change font size for all inline equations R markdown

折月煮酒 提交于 2021-02-18 12:37:01
问题 I am creating a r-markdown file and using knitr to convert to HTML. When I inline an equation such as X_1,...,X_n \sim N(0,1) it gets converted to HTML output as this . The math text is oversized relative to the plain text font. I can correct this for a single equation with \small X_1,...,X_n \sim N(0,1) . However, I would prefer not to type \small hundreds of times throughout a document. Does anyone know how to correct this with a single settings change or modification so it's applied to all

Knitr: one plot per .tabset in for-loop

旧时模样 提交于 2021-02-18 12:17:08
问题 Long story short, I'm trying to use knitr to dynamically create separate tabsets and render a plot within each tabset. Below is a description of my failed attempts. I would appreciate a solution, but I suspect I'm just not understanding the fundamental way in which knitr renders output. So if you could point me to resources or provide some conceptual guidance, that would also be appreciated. Dynamically creating the tabsets themselves is easy. Here is my .R file #' --- #' title: #' author: #'

Does rmarkdown allow captions and references for code chunks?

…衆ロ難τιáo~ 提交于 2021-02-18 11:09:40
问题 Is there a trick for captioning and referencing a chuck of code in rmarkdown (not the result of running the code)? For example, how do I reference this block of code: ```{r blah} blah <- "blah" ``` I know that I can use \@ref(fig:theFig) or \@ref(tab:theTable) to get at fig.cap or caption (with kable) but I don't see a way to caption and reference the code itself. 回答1: This would be a great feature. And I think it is not integrated yet. Here is an approach that works for PDF documents and

Insert a logo in upper right corner of R markdown html document

∥☆過路亽.° 提交于 2021-02-17 08:31:15
问题 I'm trying to put my company logo on the right corner of my html document Here my code: <script> $(document).ready(function() { $head = $('#header'); $head.prepend('<div class="knitr source"><img src="logo.png" width="220px" align="right" ></div>') }); </script> --- title: "Title" author: "Author" date: "Date" theme: bootstrap output: html_document keep_md: true --- ```{r echo=FALSE, include=FALSE} knitr::include_graphics('./logo.png') ``` <br> ## 1) Header <br> Lorem ipsum dolor sit amet,