knitr

How to use a “R-generated” plot as a semi-transparent background in an HTML5 slide made by knitr?

做~自己de王妃 提交于 2019-12-04 12:10:11
I want to add a plot to my first page of the (HTML5) slide. Can I achieve this in a dynamically way? Say, the background image will be generated by R code, rather than insert a semi-transparent PNG image. Thank you. Update : What I want is You can use the chunk option dev.args to achieve this. You will need to size the image correctly to fit your slide. ```{r dev.args = list(bg = 'transparent')} plot(1:10, 1:10) ``` This chunk will generate a transparent png. Please read the documentation ? png to get a list of arguments you can pass. Here is one useful piece onf info from the docs. png

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

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

R: Can I include an R markdown file in a shiny ui.R file?

放肆的年华 提交于 2019-12-04 10:11:01
I refer to the code example at http://shiny.rstudio.com/gallery/including-html-text-and-markdown-files.html . In my case I would like to include and R markdown file rather than a markdown. The following is my code for ui.R library(markdown) shinyUI(fluidPage( titlePanel("Tourist expenditure for the year 2012 in Malta"), fluidRow( column(2, checkboxGroupInput("id1", "Analyse by", c("Sex" = "1", "Age Group" = "2") )), column(6, h4('You entered'), verbatimTextOutput("oid1") ), column(4, includeMarkdown("intro.Rmd") ) ) )) My problem is that intro.Rmd is not compiling when embedded in shinyUI but

Title not showing on R Markdown with knitr when rendering markdown file

ぃ、小莉子 提交于 2019-12-04 09:40:54
I am trying to convert a .Rmd file to .md (output: md_document), but the title does not show up on the rendered file. The title does show up when I try to render the same file as an .html file (output: html_document). Title shows up on rendered document: --- title: "Test" output: html_document --- ```{r} head(cars) ``` Title does not show up on rendered document: --- title: "Test" output: md_document --- ```{r} head(cars) ``` rmarkdown::render(my_file) Any ideas why? I am using RStudio 0.98.1091 and R 3.1.2 on a Mac 10.9.5. The code in between -- gets interpreted, as my references are rendered

Knitting RMarkdown with ggvis to Word

杀马特。学长 韩版系。学妹 提交于 2019-12-04 09:34:56
When I try to knit a RMarkdown document with ggvis plots to Word, I get the following message from Rstudio. Error: Functions that produce HTML output found in document targeting docx output. Please change the output type of this document to HTML. Execution halted Does there exist an elegant solution (without too much effort) to make this possible, perhaps using export_png and vg2png ? Here is an example: ```{r setup, include=FALSE} library(dplyr) library(ggvis) ``` The following table looks fine... As long as I don't include this plot below ```{r, echo=FALSE, include=FALSE} p <- pressure %>%

Importing common YAML in rstudio/knitr document

天大地大妈咪最大 提交于 2019-12-04 08:34:34
问题 I have a few Rmd documents that all have the same YAML frontmatter except for the title. How can I keep this frontmatter in one file and have it used for all the documents? It is getting rather large and I don't want to keep every file in step every time I tweak the frontmatter. I want to still use the Knit button/ Ctrl + Shift + K shortcut in RStudio to do the compile keep the whole setup portable: would like to avoid writing a custom output format or overriding rstudio.markdownToHTML (as

How can I omit interactions using stargazer or xtable?

随声附和 提交于 2019-12-04 08:19:40
Is it possible to omit interactions in stargazer using the omit option? Normally I would write the variable name into the omit=c('varname') but in the case of an interaction I do not know what to write. Any hints on that? How do you solve this problem in other packages like xtable ? \documentclass{article} \begin{document} %Load dataset and run regression << lm, echo=FALSE >>= load('dataset.RData') library(stargazer) lm1 <- lm(y~ x + factor(v)*z ,data=dataset) @ << table_texstyle, echo=FALSE, comment=NA, results='asis' >>= stargazer(lm1 ,omit=c('???'), omit.labels=c('Omitted interactions'),

Generating pander tables in a loop in RMarkdown in Rstudio

三世轮回 提交于 2019-12-04 08:12:26
I've a set of tables that I'm generating with use of the code similar to the snippet below: ```{r tables, echo=TRUE, eval=TRUE} require(reshape2); require(pander) data("mtcars") data("AirPassengers") dta_lst <- list(mtcars, AirPassengers) for (i in 1:length(dta_lst)) { pander(melt(head(dta_lst[[i]], n = 2), varnames = c("Something"), value.name = "Something else"), caption = paste("Some table for: ", class(dta_lst[[i]]))) } ``` When I run the code it produces the desired output (naturally, the provided example makes little sense, in my proper data I melt the data in sensible manner): ---------