r-markdown

Dynamic number of calls to a chunk with knitr

穿精又带淫゛_ 提交于 2019-12-29 07:43:13
问题 I have such a list: > lSlopes $A Estimate 2.5 % 97.5 % 1 2.12 -0.56 4.80 $B Estimate 2.5 % 97.5 % 1 2.21 -0.68 5.10 $C Estimate 2.5 % 97.5 % 1 2.22 -2.21 6.65 It has three elements but its length can change (according to the data not shown here). I want to display each element in a chunk. My first idea was to write a chunk containing a loop calling knit_child() at each step, but I don't know how to get the correct rendering with knit_child() . I have find the following solution which works

Using image in r markdown report downloaded from Shiny app

心已入冬 提交于 2019-12-29 06:28:30
问题 I have created a very large shiny app that has a downloadable pdf report. The client has requested their logo in the header of every page of the pdf. I can get a logo on the pdf when the pdf is by itself (not part of the larger shiny app) but pandoc cannot find the image when I try to download the exact same report from within the shiny app. Below is a minimum working example and a list of things I have tried and failed to get to work. smiley.png is in the folder with app.R and can be

Rstudio 0.98.1028 add background image only to title slide

牧云@^-^@ 提交于 2019-12-29 06:25:25
问题 I am attempting to create a R Presentation (.Rpres) using RStudio 0.98.1028 with a different background image on the title slide and another background image on the rest of the slides. I am able to place a custom background (foo.png) by creating a css file with this in it: body { background-image: url(foo.png); background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-size: 100% 100%; } I was able to turn off the default color scheme on the

Evaluate inline r code in rmarkdown figure caption

纵饮孤独 提交于 2019-12-29 06:13:44
问题 I am using RStudio and knitr to knit .Rmd to .docx I would like to include inline code in figure captions e.g. something like the following in the chunk options: fig.cap = "Graph of nrow(data) data points" However, knitr does not evaluate this code, instead just printing the unevaluated command. Is there a way to get knitr to evaluate r code in figure/table captions? 回答1: knitr evaluates chunk options as R code. Therefore, to include a variable value in a figure caption, just compose the

R markdown: How to create a table with images and text which should be knitted as PDF?

只愿长相守 提交于 2019-12-29 01:53:10
问题 I would like to include a table with 2 columns including images and text (image descriptions) in PDF report compiled with R markdown. In doing so, I have the following requirements for my table: width: fixed column or table width alignment: content alignment in columns top center alignment of an image in column 1 top left alignment of text in column 2 text content: is at best easy and good to read also in code text formatting: text formatting required, at best using markdown syntax, i.e, bold

rmarkdown::render to compile LaTeX documents

大兔子大兔子 提交于 2019-12-25 09:14:24
问题 This example LaTeX file compiles just fine for me using Rstudio, TexShop, and pdflatex example.tex . But rmarkdown::render does not work. > rmarkdown::render("example.tex", output_format = "pdf_document") /usr/local/bin/pandoc +RTS -K512m -RTS example.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output example.pdf --template /Library/Frameworks/R.framework/Versions/3.3/Resources/library/rmarkdown/rmd/latex/default.tex --highlight-style

HTML formatted tables in rmarkdown word document

吃可爱长大的小学妹 提交于 2019-12-25 09:11:32
问题 I have to compare some values in data and display weekly trends. I want to show if a value has increased from last week. I have created an rmarkdown report to do it. An example code is shown below, which works perfectly when output: html_document but output is messed up when using output: word_document --- title: "trials" author: "Foo Bar" date: "15 December 2016" output: word_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ```{r cars, echo=FALSE, cache=FALSE,

Create pdf-format table that can wrap the text well in rmarkdown

☆樱花仙子☆ 提交于 2019-12-25 04:57:15
问题 I used the rmarkdown to create a pdf file, where some tables are included in the output. The tables are created by using pander function. As you see, the output does not wrap the text well, so the output is quite dirty. Suppose the code is as follows: title: "Untitled" output: pdf_document --- ```{r kable} library(xtable) a <- rep(1,5) b <- rep("33333333333333333333333333333333333333333333333333333333333333333", 5) c <- rep("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh",

Put figure directly into Knitr document (without saving file of it in folder) Part 2

对着背影说爱祢 提交于 2019-12-25 04:15:29
问题 I am extending a question I recently posted here (Put figure directly into Knitr document (without saving file of it in folder)). I am writing an R package that generates a .pdf file for users that outputs summarizations of data. I have a .Rnw script in the package (here, my MWE of it is called test.Rnw). The user can do: 1) knit("test.Rnw") to create a test.tex file 2) "pdflatex test.tex" to create the test.pdf summary output file. The .Rnw file generates many images. Originally, these all

Shortcut for commenting in Rmarkdown?

一笑奈何 提交于 2019-12-25 02:58:31
问题 Simple question: does anyone know of a shortcut key for commenting in Rmd? In Knitr this can be done using CTRL + C, which produces in both writing and coding environment a comment line. This does not work in Rmd unfortunately. At the moment I have to type out: <!-- Comments --> I am using R-studio. 回答1: Add a snippet under the "markdown" section: (I made mine hcm ) then type: hcm Shift Tab and it'll expand to whatever you want (mine was <!-- --> ) You can make the snippet text shorter as