r-markdown

Using R markdown and knitr: Possible to get R objects interpreted in YAML

霸气de小男生 提交于 2019-12-07 11:57:17
问题 I am using knitr , R markdown , and a custom LaTeX file to write a manuscript. The abstract is set as part of the YAML frontmatter. This works great, except that the results that I would like to include in the abstract are generated later in the document. Having the abstract in the YAML makes some sense to me and I would prefer to keep it this way. Any thoughts on a way to have the abstract take advantage of calculations that happen later in the document? A brief example: --- title: 'How do I

Internationalization R knitr Figure caption label

风格不统一 提交于 2019-12-07 11:57:07
问题 I want to generate a Latex document with knitr, but it does not allow me to change the label for the figure into my language. The code: ```{r rstudio, echo = FALSE, fig.cap = "RStudio IDE", fig.margin = T} plot(pressure) ``` This generates: However I want the caption label to read Figura: (portuguese) instead of Figure: . I added the variable lang: pt-br , which corrects for when I call it with \@ref(fig:rstudio) , but does not fixes the figure label. How to change the caption label in

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

≡放荡痞女 提交于 2019-12-07 11:22:09
问题 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? 回答1: PDF document Use LaTeX \hfill command: This

Greek letter in title of R Markdown document

本小妞迷上赌 提交于 2019-12-07 09:53:40
问题 Is it possible to include a Greek letter in the title of R markdown document? I tried this: --- title: "α-Amylase" author: "author" date: "8 March 2017" output: pdf_document: keep_tex: true toc: yes toc_depth: 6 --- And this: --- title: "$\alpha$-Amylase" author: "author" date: "8 March 2017" output: pdf_document: keep_tex: true toc: yes toc_depth: 6 --- 回答1: This should work, with html it gives the following output: --- title: \(\alpha\)-Amylase author: "author" date: "8 March 2017" output:

How to render table from htmlTable package in pdf_document in rmarkdown?

大兔子大兔子 提交于 2019-12-07 09:46:28
问题 Within rmarkdown (in RStudio) I use htmlTable package to generate nice looking tables in my html documents. Now I want the same result when rendering a pdf document. The tables aren't rendered properly. How can I let rmarkdown generate tables in my pdf document the same way it does in my html's? This is a working example of a .Rmd file with a table: --- title: "test" output: pdf_document --- ```{r results="asis"} library(htmlTable) c1 <- c("test1","test1","test2","test2") c2 <- c(1,2,3,4)

Display python plotly graph in RMarkdown html document

依然范特西╮ 提交于 2019-12-07 09:08:57
问题 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

How can I subscript names in a table from kable()?

走远了吗. 提交于 2019-12-07 08:40:41
问题 Given a data.frame A, how can I use subscripted rows and columns names? Eventually I want produce a table through kable() in rmarkdown (output: word document). A <- data.frame(round(replicate(3, runif(2)),2)) rownames(A) <- c("Hola123", "Hola234") A X1 X2 X3 Hola123 0.47 0.55 0.66 Hola234 0.89 0.45 0.20 How could I make all numbers from row and column names subscripted when creating a table through kable(A)? I have tried: rownames(A) <- c(expression(Hola["123"]), expression(Hola["234"]))

R: output a pivot-like table with subtotals

五迷三道 提交于 2019-12-07 06:12:32
问题 I'm trying to make a cross tabulation in R, and having its output resemble as much as possible what I'd get in an Excel pivot table. The objective is to replace a report made manually with Excel and Word with one automated with R Markdown; data wrangling and charts have been already taken care of but some tables are missing. So, given this code: set.seed(2) df<-data.frame("ministry"=paste("ministry ",sample(1:3,20,replace=T)),"department"=paste("department ",sample(1:3,20,replace=T)),"program

Render code for google chart in rmarkdown Rmd

醉酒当歌 提交于 2019-12-07 05:49:43
问题 Google has some nifty charts. I'm sure there's nice R wrapper packages to do what I want but I want to learn how to include a google chart myself as it will likely be more flexible than an R wrapper for including a google chart. Below is an .Rmd that has a donut function to produce the donut from Google chart gallery. The function outputs a code as expected seen below but to actually knit this results in the following pandoc conversion error. How do I include the google chart code properly in

sourcing References in rmarkdown: workaround

本秂侑毒 提交于 2019-12-07 05:24:01
问题 I am working with markdonw v2, the rmarkdown package. Throughout the .Rmd file, I create links to websites or images [Link1][pathLink1] ![Image1][pathImage1] then, at the end of the document I give the references [pathLink1]:http://website.com/linkes/Link1.md ![pathImage1]:./images_rmd/ There are other reports that talk about the same citation and use same images in different contexts. I would like to create a separate file containing all the links and path difinitions, so that I could simply