r-markdown

Center leaflet in a rmarkdown document

假如想象 提交于 2019-12-06 14:28:56
I want to create an html document with a centered leaflet widget inside it. --- title: "Exemple" author: "Antoine Bichat" date: "31/08/2018" output: html_document --- ```{r leaflet, fig.align="center"} library(leaflet) leaflet() %>% addTiles() %>% addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R") ``` The first idea with fig.align="center" doesn't work. I found this question and I adapted it to my case: <style> /* resize the widget container */ .leaflet { width: 80% !important; } /* center the widget */ div.leaflet-control-container { margin: auto !important; } </style> but if I

Rmarkdown - how to remove grey background on output

不问归期 提交于 2019-12-06 14:07:58
问题 I am experiencing a slightly irritating problem, which is that I am not able to remove the grey text from output (please see picture below). I've searched for a solution, but is restricted by my lack of knowledge about the proper terms, and therefore I am not able to find any solutions. I know this can be somehow bypassed by using only one "`", yet I need the triple "```" in order to run my code interpreting rows. The grey background on output --- title: "Untitled" output: word_document --- `

Cache SQL chunk with R Markdown / Notebook without Knitting in RStudio

旧街凉风 提交于 2019-12-06 14:07:17
I have a chunk of SQL in my R Markdown / Notebook Document: ```{sql output.var = "df"} SELECT * FROM FakeData WHERE Date >= '2017-01-01 ``` It takes literally 5 minutes to run. Is there an easy way to cache the result of the query without Knitting the document or writing the file to a CSV. I'd perhaps like the cache to live for a couple of hours, or maybe a day (is there a way to adjust this as well?) If you put cache=TRUE in the chunk options and you are working in rStudio, you can select a section of code and run it directly using the green arrows in the upper right of the rMarkdown/knitr

How to solve R Markdown (Knit) “'closure' is not subsettable”?

﹥>﹥吖頭↗ 提交于 2019-12-06 12:31:48
I am trying to use RMarkdown (Knit) for the first time to produce pdf. The default file (File > New File > R Markdown) works well, it shows the generated pdf when compiled. For example, the following code runs, ```{r cars} summary(cars) ``` However, if I just change cars with "myData," it does not compile and shows, Error in object[[i]] : object of type 'closure' is not subsettable Calls: <Anonymous> ... withVisible -> eval -> eval -> summary -> summary.default Execution halted I have "myData" loaded in the global-environment and can do other operations in original R script. Can someone please

How to add a watermark image on rmarkdown?

淺唱寂寞╮ 提交于 2019-12-06 12:07:45
I'm searching and trying to add a image as watermark to rmarkdown pdf, I'm using the render function to generate the PDFs, and saw the \usepackage{draftwatermark} and this question: Watermark in rmarkdown But they don't help me in adding a image as watermark. --EDIT-- I achieved what I wanted putting this to the header of .Rmd: header-includes: - \usepackage{eso-pic,graphicx,transparent} And placing this in the start of file (before the rest of .Rmd): \AddToShipoutPictureFG{ \put(0,0){% \parbox[b][\paperheight]{\paperwidth}{% \centering {\transparent{0.3} \includegraphics[width=\paperwidth

Generate report with Shiny app and Rmarkdown

旧城冷巷雨未停 提交于 2019-12-06 11:54:41
问题 I would like to create a shiny app that allows you to download a report. Right now I'm trying to keep things super simple and the only input on the shiny app is some text that the user can input using textarea : library(shiny) server <- function(input, output) { output$downloadReport <- downloadHandler( filename = function() { paste('my-report', sep = '.', switch( input$format, PDF = 'pdf', HTML = 'html', Word = 'docx' )) }, content = function(file) { src <- normalizePath('report.Rmd') #

Adding space around figures in RMarkdown

扶醉桌前 提交于 2019-12-06 11:47:50
问题 I would like to add space around figures in RMarkdown. I am knitting to PDF and really don't like how close figures (or also equations) are to the text or to the next figure. --- output: pdf_document --- ```{r pressure, echo=FALSE} plot(pressure) ``` ```{r pressure2, echo=FALSE} plot(pressure) ``` There is just too little space between the two plots and this gets more fuzzy when using ggplots. Right now I use the Latex solution \vspace{10pt} but it would be nice if I could make a setting

knitr::include_graphics in bookdown, is not rendering the image

自作多情 提交于 2019-12-06 11:30:18
I am trying to include a .png file in a file that I am rendering using bookdown. knitr::include_graphics() should be the way to go. The code: ```{r fig1, fig.cap='My Caption', echo=FALSE, message=FALSE, warning=FALSE} knitr::include_graphics("./Figures/My Figure.png") ``` In the .Rmd file, I can run my r block, and it renders the image below. So, the path should be correct. However, when I knit the chapter, or render the entire book, the figure is not rendered. Could it be that some of my other options are overriding the figure? Below are my YAML header of the index.Rmd file, and the code in

servr::jekyll() yields ready website, servr:rmdv2() does not

落花浮王杯 提交于 2019-12-06 11:10:45
I'm basing my rmarkdown -Jekyll-Blog off of Yihui's fantastic boilerplate for using servr::jekyll() , which in turn wraps knitr . Because I want to use citations (via pandoc-citeproc , wrapped by rmarkdown ) I need to use rmarkdown::render , not knitr to, well, render the *.md s. As per the servr manual, I understand that rmdv2() should do the job, which essentially wraps/modifies jekyll() : The functions rmdv1() and rmdv2() are similar to jekyll(), and the only difference is the way to compile R Markdown documents: rmdv1() uses the markdown package (a.k.a R Markdown v1) via knit2html(), and

get rid of captions when using texreg in Rmarkdown

匆匆过客 提交于 2019-12-06 10:13:14
How do you suppress captions for a texreg table? I'm using Rmarkdown to generate a LaTeX file. Here's a simple example: ```{r, echo=FALSE, message=FALSE, results="asis"} library(texreg) data <- data.frame(a=c(1,2,3,4), b=c(6,3,4,4)) texreg(lm(a~b, data=data), caption="", custom.note="", float.pos="h!") ``` The table I get has a caption on the bottom that says "Table 1:". How do I get rid of it? Thanks. In the YAML section where LaTeX packages can be included, add the caption package: header-includes: - \usepackage{caption} Then at the beginning of the RMarkdown document body add: \captionsetup