knitr

save heatmap generated by d3heatmap

↘锁芯ラ 提交于 2020-01-24 10:54:13
问题 I'm trying to save a heatmap produced by d3heatmap to a pdf file, but the file is always damaged. library(d3heatmap) pdf(file="heat.pdf") d3heatmap(mtcars, scale = "column", colors = "Spectral") dev.off() I suspect the challenge is "this is an R package that implements a heatmap htmlwidget." However, I figured I could still capture the image produced because "Like any htmlwidget, you can visualize a d3 heatmap directly from the R console." I looked at the two output functions in the package,

knitr chunk options to control line spacing, font size in output

不想你离开。 提交于 2020-01-24 06:47:13
问题 I'd like to have more control over the font size and line spacing used for code chunks and R output via LaTeX. Using the default render_latex(), I see I can set both globally using (in my premable) \renewenvironment{knitrout}{\small\renewcommand{\baselinestretch}{.85}}{} ... \begin{document} But, say there are chunks I'd like to print in \footnotesize, or customize in some other way. I know I can do this with a LaTeX group, but not with the knitrout environment: {\small \renewcommand{

R markdown ioslides incremental mode for code chunks

泄露秘密 提交于 2020-01-24 03:03:32
问题 How do you turn R code chunks to appear incrementally? For example, I put the following option in the header: --- ...other configurations... output: ioslides_presentation: incremental: true --- But the incremental mode only applies to bullets and not to the code chunks ## Slide 1 * this bullet point appears first * this bullet point appears second ```{r eval=FALSE} # This chunk is there from the beginning ``` So my question is : How do you make the chunk appear after the second bullet? 回答1:

custom R Markdown plot size within loop

你离开我真会死。 提交于 2020-01-24 01:09:08
问题 I'm creating strip plots within a R Markdown/knittr document. I would the like vertical size of the plots to be proportional to the number of rows in the strip plot. EDIT: The best solution would also allow interleaving of tables and plots. See Interleaving tables and plots in R Markdown, within loop In this example, the plot for MPG for cars with "3 Carburetors" is the same height as the plot for cars with "2 Carburetors", even though there are three different gear configurations for 2

function to get filename without full path in YAML header of RMarkdown document

◇◆丶佛笑我妖孽 提交于 2020-01-23 19:59:25
问题 I am trying to modify the behavior of RStudio's knit button, by changing the directory to which it writes the output of knitting the Rmd file. I have started with this answer, but instead of having the filename given by a fixed string, I'd like to have the output filename based on the Rmd filename. However, the variable inputFile includes the full path to the Rmd file. Is there a way to get only the filename without the path? The header I am working with that produces the full path+filename

Converting Markdown to HTML5 slides via Pandoc through knitr in R

吃可爱长大的小学妹 提交于 2020-01-22 15:56:08
问题 Since version 1.2 knitr has a new function pandoc to convert markdown document to other formats via pandoc directly in R (See here). For example library(knitr) pandoc('foo.md', format='html') # HTML I wonder how to convert Markdown document (See knitr-slides.md for MWE) to HTML5 slides. Thanks 回答1: First, add the following to your .Rmd document: <!--pandoc s: S: i: mathjax: --> Then use the command library(knitr) knit("foo.Rmd") pandoc("foo.md", format="dzslides") This will still create the

Display a data frame as table in R Markdown

穿精又带淫゛_ 提交于 2020-01-22 14:12:09
问题 In knitr I want to add a (small) data frame as a table using the kable package: --- output: html_document --- ```{r} knitr::kable(mtcars[1:5,1:5], format="html") ``` This returns a compact table as above, while changing it to format="markdown" returns a nice table but spanning the whole page: I have found the knitr manual but it does not cover the extra formatting options for each format. How can I change the size of a knitr table or even better, where can I get this information from? 回答1:

Use internal links in RMarkdown HTML output

拈花ヽ惹草 提交于 2020-01-22 06:42:28
问题 I am using R Studio to create a markdown document. I tried: Jump to [Header 1](#anchor) I would like to set up a link so when a reader clicks it, can jump to a specific point on the page. Let's say the point I want them to be directed to has a header " ##Test ". 回答1: Here is a solution for HTML documents using jQuery: --- title: "Internal Links" output: html_document --- # First Section ## Second Section ### Third Section <script type="text/javascript"> // When the document is fully rendered.

Using table caption on R markdown file using knitr to use in pandoc to convert to pdf

一世执手 提交于 2020-01-20 17:26:46
问题 I am wondering if it is possible to use the table captions like figure captions using knitr in .Rmd file ? I saw options for figure caption but I couldn't see the option for the table caption. I also want to remove the message such as "% latex table generated in R 2.15.2 by xtable 1.7-0 package % Wed Mar 06 15:02:11 2013" . I used X table to create the table: The sample code I used is as follows: ```{r table2, results='asis', message=FALSE} library(xtable) print(xtable(head(iris))) ``` The

Using table caption on R markdown file using knitr to use in pandoc to convert to pdf

大兔子大兔子 提交于 2020-01-20 17:25:29
问题 I am wondering if it is possible to use the table captions like figure captions using knitr in .Rmd file ? I saw options for figure caption but I couldn't see the option for the table caption. I also want to remove the message such as "% latex table generated in R 2.15.2 by xtable 1.7-0 package % Wed Mar 06 15:02:11 2013" . I used X table to create the table: The sample code I used is as follows: ```{r table2, results='asis', message=FALSE} library(xtable) print(xtable(head(iris))) ``` The