r-markdown

Is it possible to have sortable (Interactive) table in rMarkdown?

浪子不回头ぞ 提交于 2019-12-03 11:06:00
问题 I am using kable() from knitr package to show a table on a html document. Is it possible to make it sortable? Some sample code, --- title: "Test" output: html_document --- ```{r, echo=FALSE, comment=""} kable(data.frame("a"=1:10,"b"=11:20),digits=2) ``` 回答1: The package DT (https://github.com/rstudio/DT) is an R interface to the JavaScript library DataTables. You can use it in R Markdown, e.g. ```{r} DT::datatable(iris) ``` 来源: https://stackoverflow.com/questions/27120002/is-it-possible-to

R markdown table with a caption

烈酒焚心 提交于 2019-12-03 10:39:24
I'm trying to create a table outside of a code chunk using normal markdown notation and to add a caption to it. Here's an example file (taken from here : --- output: pdf_document --- | First Header | Second Header | Third Header | | :------------ | :-----------: | -------------------: | | First row | Data | Very long data entry | | Second row | **Cell** | *Cell* | | Third row | Cell that spans across two columns || [Table caption, works as a reference][section-mmd-tables-table1] This unfortunately produces a rather sad string: Removing the caption line in square brackets produces the table

How to remove white space above and below image in R Markdown?

余生颓废 提交于 2019-12-03 10:32:48
I want to export a .Rmd file primarily as a latex pdf. This is the code that I'm currently using ```{r ,fig.cap="caption",fig.env='figure', fig.width=10, fig.height=10,echo=FALSE, results='asis', warning=FALSE, strip.white=TRUE} library(png) library(grid) img <- readPNG("filepath/overview.png") grid.raster(img) ``` As you can see, I'm already using strip.white=TRUE & fig.env='figure' but they don't seem to work. The .PNG file hasn't got any (white) spacing above or below the image. I know I can use latex directly and achieve what I want, but I want to able to reproduce this in Word if needed.

knitr/Rmd: page break after n lines/n distance

梦想的初衷 提交于 2019-12-03 10:22:27
问题 Let me caveat by saying that this may be better suited as an html/css question but (a) I'm not too familiar with those techniques and (b) I wanted to keep it all in the family (R family) if possible. I would like to use knitr to write academic style reports ( APA 6 type guidelines ) using Rmarkdown. I've got most aspects worked out but not page breaking. I can manually set page breaks with something like: # report ```{r setup, include=FALSE} # set global chunk options opts_chunk$set(cache

Why Pandoc does not retrieve the image file?

久未见 提交于 2019-12-03 10:12:34
问题 On RStudio version 0.98.501 I had a long .Rmd file which was easily converted to html once I clicked KnitHtml button. The Knitting process, as I understand, created several folders including images (some manually added by myself), figures, cache and a knitHtml folder which included final .html file. I recently downloaded RStudio version 0.98.894 (preview release) because I wanted to use more features. Now, when I click knitHtml I get following error: pandoc.exe: Failed to retrieve C:/Users

Plots in beamer slides converted from .md by pandoc are extremely large

二次信任 提交于 2019-12-03 09:30:16
问题 Normal plots generated by R chunks in R markdown files are exactly there when converted to html slides or pdf. However, when they are converted to beamer slides by pandoc -t beamer ex.md -V theme:Warsaw -o beamer.pdf , the plots become extremely large, especially for those generated by par(mfrow=c(n,m)) , in which case only a little part of the plot is displayed. I tried to fix by setting the chunk option dev='pdf' , but it doesn't work out. The plot in html is The plot in beamer is 回答1: The

How to add an interactive visualization to R markdown

断了今生、忘了曾经 提交于 2019-12-03 09:27:24
问题 My question is I want to integrate a d3.js visualization to my markdown rather than a link pointing to the visualization on external website. Is there a way to achieve that? 回答1: To accomplish adding nonlocal javascript such as d3.v3.min.js to our Rmd, there are a couple ways to do it. If you are looking to include local copy of d3 , it is much easier. This is my favorite way. If for some reason, you would like to see the others, I will be happy to show them. Note: I am still experimenting. -

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

徘徊边缘 提交于 2019-12-03 09:05:11
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. 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} }% } And add to your yaml: --- output: pdf_document: includes: in_header: header.tex --- See the

Change RStudio Default R Notebook to blank

ⅰ亾dé卋堺 提交于 2019-12-03 08:46:42
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? 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-blank

Using a YAML header argument in knitr

萝らか妹 提交于 2019-12-03 08:13:42
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 to define the name of the files. The basic idea being that I want to have one .rmd file for my slides,