r-markdown

Adding background image to R Markdown (.rmd) file for PDF output?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 14:16:21
问题 Is it possible to add a background image to a R Markdown (.rmd) file for PDF output? I have scoured through Pandoc's R Markdown documentation but cannot find any mention of adding a background image. 回答1: From this tex.SE answer: save the following as header.tex (replacing image.jpg by the path to your background image): \usepackage{background} \backgroundsetup{ scale=1, color=black, opacity=0.4, angle=0, pages=all, contents={% \includegraphics[width=\paperwidth,height=\paperheight]{image.jpg

Change RStudio Default R Notebook to blank

╄→гoц情女王★ 提交于 2019-12-04 13:26:46
问题 The default R Notebook has a lot of prepopulated text. Is there a way to change this, so that when a new R Notebook is created, it is just a blank notebook? 回答1: On my machine (OSX) I can edit the template r_markdown_notebook.Rmd found at this location: /Applications/RStudio.app/Contents/Resources/resources/templates On Windows look inside the RStudio folder: C:\Program Files\RStudio\resources\templates 来源: https://stackoverflow.com/questions/41333954/change-rstudio-default-r-notebook-to

Automate RStudio processed RMarkdown?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 13:01:32
I have an RMarkdown file that I use to generate a nice HTML report. The problem is, I want to be able to automate it so that it can run on a headless server. As such there will be nobody there to start Rstudio and press the 'knithtml' button and it seems that Rstudio is doing a LOT of additional magic like having it's own version of pandoc, running all the necessary commands, applying css styles etc. How can I take this report and generate the same thing Rstudio is generating when I press the 'knithtml' button, but by just running an R script? Thanks. Try using rmarkdown::render("/PATH/TO/YOUR

Automatically generated reports using rMarkdown

橙三吉。 提交于 2019-12-04 11:42:37
I am trying to generate about 50 reports with the same template in rMarkdown. I do not want to change the name of the input file every time and I would like to choose different names for output files. Is there any way how to automate this process? Thank you. Another option is to render your reports using the render() function of the rmarkdown package in a seperate R script. report.Rmd looks like this: --- output: pdf_document --- # A table with data received from R script ```{r,results='asis'} library("knitr") kable(mydataset) ``` The R script looks like that: library("rmarkdown") for (i in 1

Using a YAML header argument in knitr

浪子不回头ぞ 提交于 2019-12-04 11:33:06
问题 I am making a set of slides using rmarkdown and the LaTeX option of outputting it to beamer . I have two templates I use in my slides - one specific for the LaTeX options, and one pandoc template that I have modified to account for some additional feature of my slides. I have defined an option in the YAML header called to_print which is a boolean TRUE/FALSE that I pass to the pandoc template that tells it to add a package and clean up the slides for printing. I also want to use this variable

Stargazer output is code, not a table

Deadly 提交于 2019-12-04 11:25:25
I am trying to use the package stargazer in RStudio to generate a summary table of my data. For some reason, I am not able to view the table in the output when I use either the html or latex code, but I can see it when I output as text. An example: library(stargazer) stargazer(attitude, type = 'text') Output looks like (as it is supposed to): ## ## ===================================== ## Statistic N Mean St. Dev. Min Max ## ------------------------------------- ## rating 30 64.633 12.173 40 85 ## complaints 30 66.600 13.315 37 90 ## privileges 30 53.133 12.235 30 83 ## learning 30 56.367 11

Why does datatable not print when looping in rmarkdown?

烈酒焚心 提交于 2019-12-04 11:14:35
I am working on creating a dynamic rmarkdown document. The end result should create a tab for each 'classification' in the data. Each tab should have a datatable, from the DT package, with the data printed to it. Below is the code I have been using: --- output: html_document --- # Setup{.tabset} ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) library(knitr) library(DT) ``` ```{r data.setup} set.seed = 1242 rows = 64 data.1 = runif(rows, 25, 75) data.2 = runif(rows, .01, 1) data.3 = runif(rows, 1, 10) classification = c("A", "B", "C", "D") df = data.frame(cbind(data.1 = data.1,

Shiny Presentation (ioslides): Custom CSS and logo

半世苍凉 提交于 2019-12-04 10:51:23
问题 I have the following installed: preview release of RStudio, Version 0.98.864 (May 24th, 2014) development versions of knitr and shiny, via devtools::install_github(c("yihui/knitr", "rstudio/shiny")) I would like to create a Shiny Presentation (RStudio menu items: File>New File>RMarkdow>Shiny>Shiny Presentation) with custom CSS but am unsure how to do so. My custom CSS (which currently only changes the colour of header 2) h2 { font-size:1.8em; color: red; } works with an extract of an example

Rmarkdown to LaTeX

风格不统一 提交于 2019-12-04 10:47:32
问题 I made a presentation in RStudio with RMarkdown/Knitr - it compiles without problems to a pdf (via LaTeX Beamer). But I cannot get the LaTeX file. Is there any way to export also the LaTeX file which should be produced in the conversion? 回答1: In RStudio: Click the gear - options button next to knit. Click output options. Click advanced. Click Keep tex source file . . . to answer the 1st comment, here is some sample LaTeX \begin{Shaded} \begin{Highlighting}[] \NormalTok{DF <-}\KeywordTok{read

add and resize a local image to a .Rmd file in RStudio that will produce a pdf

对着背影说爱祢 提交于 2019-12-04 10:20:07
问题 I am trying to add and resize a local image to a .Rmd file in RStudio that will produce a pdf. I can add the file easily with ![My caption.](path/file.png) but I have not figured out how to control the size of the image. I tried HTML code with a width attribute, but the image would not appear (I think this only works if outputting to HTML). <img src="path/file.png" width="200px" /> I could not get this idea to work: ![My caption.](path/file.png =250x) Is there a way to modify the Rmarkdown