r-markdown

Can I set the CSS/JS paths parametrically in Xaringan YAML?

南笙酒味 提交于 2019-12-05 21:41:17
This is similar to Xaringan issue #29 . I'm setting up a Xaringan template to be used at work, and I want to keep all the CSS and Javascript files in the same location. I don't want anyone to have to copy the same files into each presentation directory. However , I also don't want to refer to a common root directory. I could (I think) point to our in-house Bitbucket server, but I would much rather analysts and data scientists be able to get the files from their local repo (for speed, and also in case they're not on the network or are making their own changes). I'm also not particularly hung up

Change font of Kable in Rmarkdown pdf

馋奶兔 提交于 2019-12-05 21:35:12
Is there a way to change the font of a kable in Rmarkdown when knitting to pdf? I can find plenty on changing size or bold etc but not on changing the actual font. I would just like something sans serif. Example markdown doc: --- title: "R Notebook" output: pdf_document: default --- Change the font in the table below: ```{r message=FALSE, warning=FALSE, echo=FALSE} library(kableExtra) mtcars %>% head() %>% kable() ``` Default table output font You can use the Latex fontspec library , see below. Note that you can see your available fonts and their names in the Fonts page from Settings. ---

Loops in Rmarkdown: How to make an in-text figure reference? Figure captions?

老子叫甜甜 提交于 2019-12-05 21:34:33
{r setup, include=FALSE, message=FALSE, results="hide"} knitr::opts_chunk$set(echo = TRUE) library(knitr) library(kfigr) library(dplyr) library(png) library(grid) library(pander) library(ggplot2) Question Loops in rmarkdown: in-text figure reference? figure captions? Goal Use a for loop to create sections with text, in-text results, and multiple figure references with associated figure captions in the figure list. The figure references/numbering should be seemless with figures numbered before and after these new sections. Note: The figures referenced in the for loop are generated earlier in

Accessing YAML parameters as macros within external LaTeX files

强颜欢笑 提交于 2019-12-05 21:24:33
问题 I'm looking for ways to add variables (or LaTeX macros) to the YAML header or soon after such that they can be used in external .tex files that are a part of my (modularised) report. My .rmd file --- output: pdf_document: latex_engine: xelatex includes: before_body: some.tex params: cat: "Felix" numb: 14 --- # chapter Oh my \textbf{`r params$cat`}. $x = `r 2*params$numb`^2$ <!-- Trying again to get the parameter --> \input{some.tex} My some.tex file: `r params\$cat` Output Hoped-for output I

Increment section numbers in PDF output

雨燕双飞 提交于 2019-12-05 21:22:17
I'm trying to increment the section headers in my rMarkdown (PDF output) file by 1. Instead of # First resulting in 1 First , I'd like 2 First. I found a way to define the offset in html_output using the following syntax, but it doesn't work for pdf_output. --- title: "Untitled" author: "author" date: "date" output: html_document: toc: true pandoc_args: [ "--number-sections", "--number-offset=1" ] --- # First Header # First SubHeader This results in 2 First Header 2.1 First Subheader However, this syntax does not work for PDF documents: --- title: "Untitled" author: "author" date: "date"

How to create a table in Rstudio presentation

流过昼夜 提交于 2019-12-05 19:25:39
I'm trying to create a table in an RStudio .Rpres file. Below is what I have at this point from online searching but the alignment is not correct. Is this the best method? Any suggestions on the alignment? Test ========================================================= | Right | Left | Default | Center | |------:|:-----|---------|:------:| | 12 | 12 | 12 | 12 | | 123 | 123 | 123 | 123 | | 1 | 1 | 1 | 1 | : Demonstration of simple table syntax. Result: You can use knitr::kable to print your data.frame Test ======================================================== ```{r, echo=FALSE} my_df <- iris

Coverpage and copyright notice before title in R bookdown?

穿精又带淫゛_ 提交于 2019-12-05 18:11:45
Back in March, I asked a question and got an answer to including coverpage in a pdf document rendered by R bookdown: R bookdown - cover page and appendix I tried the solution and came up with the following results: using in index.rmd yaml: output: pdf_document: includes: before_body: frontpage.tex number_sections: yes toc: yes toc_depth: 3 site: bookdown::bookdown_site documentclass: book classoption: letterpaper The title still appeared before the coverpage AND the Chapter 'wording' in chapter titles (ie 'Chapter 1' before the actual words for chapter title) disappeared. And the section

how do we right align part of a line in r markdown?

浪尽此生 提交于 2019-12-05 16:56:45
I am working on an R markdown document and was trying to see if we can right align the end of a sentence. The sentence should look like : This is the same sentence's first part < spacespacespace space space > this is the end of sentence. I have tried comibining LaTeX syntax with it This is the same sentence's first part \begin{flushright} sample end of sentence \end{flushright} But this doesnt give the desired effect. Can someone please help? PDF document Use LaTeX \hfill command: This is the same sentence's first part \hfill this is the end of sentence. HTML document Use CSS float property.

how to add grid to table with pander?

梦想与她 提交于 2019-12-05 16:37:27
I am working with R, knitr and pander, and I can't find the option that would allow me to print a grid on a table with pander. I tried : pander(tableToPrint, style='grid') but it doesn't do anything, neither with this option or with 'multiline', 'rmarkdown'... I always get an horizontal line, then the column names, another horizontal line, all my data and an horizontal line. I would like to have an horizontal line between every line. Another option would be to alternate row colors. scoa There is an old answer that gives the trick to do that in latex, but in needs a bit of adaptation to pandoc.

Display python plotly graph in RMarkdown html document

徘徊边缘 提交于 2019-12-05 14:52:24
Why plotly package of python can not display figure in RMarkdown but matplotlib can? For example: ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE) ``` ```{r} library(plotly) subplot( plot_ly(mpg, x = ~cty, y = ~hwy, name = 'default'), plot_ly(mpg, x = ~cty, y = ~hwy) %>% add_markers(alpha = 0.2, name = 'alpha'), plot_ly(mpg, x = ~cty, y = ~hwy) %>% add_markers(symbols = I(1), name = 'hollow') ) ``` ```{python} import plotly import plotly.plotly as py import plotly.graph_objs as go import numpy as np plotly.tools.set_credentials_file(username='xxx