How to integrate R code in markdown and then insert the plots in the rendered document?
I use the blogging engine Hakyll (http://jaspervdj.be/hakyll/).
It uses Pandoc as a back-end for rendering blog posts written in markdown.
There's even a special markdown flavor named R-markdown. It can be rendered to plain markdown using the knitr package.
Apparently the link provided directs to a page about R-markdown V2 which has its own package rmarkdown.
FYI I published a package that allows to compile Rmd posts in Hakyll:
https://hackage.haskell.org/package/hakyll-R
For the moment I write my blog post in Rmarkdown, and transform it in plain markdown with:
Rscript -e "library(knitr); knit('myPost.Rmd')
Then Hakyll can process it. More details here: http://www.corentindupont.info/blog/posts/Programming/2014-12-10-This-Blog.html.
I would be glad to know if this command can be integrated directly into Hakyll.
Related
I am making a presentation in latex (Oxygen Beamer Template) in the online latex editor Overleaf, it is the original template that overleaf is available to modify it, the idea is to be able to implement it in Rmarkdown. So my question is if there is any package in R or trick to be able to capture the result of latex as a presentation in Rmarkdown?
Anyway when I have an advance or discover something I share it in this same way.
Thanks for your time, regards!
Hi knitr experts: I cannot for the life of me figure out how to compile the knitr Miminal Demo .Rnw document correctly. When I download and run Yihui's Minimal Demo of knitr .Rnw file (link), the document compiles but incorrectly handles the R chunks:
I changed nothing, just opened and compiled. Help welcome. As an aside, would very much appreciate tips on whether this is how I should be going about adding R code into a latex template that UT-Austin requires for dissertation publication. Thanks.
I can reproduce your PDF file when using Sweave instead of knitr for translating the .Rnw file. When switching to knitr via the RStudio options (c.f. https://support.rstudio.com/hc/en-us/articles/200532247), I get an error message and no PDF, which probably reproduces #r2evans' results in the comments. I also get a warning message that line 19 is Sweave specific (\SweaveOpts{concordance=TRUE}). Removing that line, the file processes with knitr correctly producing
I have been using .Rmarkdown files to create blog posts in R blogdown. The output of chunk of codes in .Rmarkdown documents are printed in the console and not in the document.
If instead I create a .rmd file, then previews are in window. RStudio Global options are set to show preview in window for RMarkdown documents.
Is this an expected behavior of .rmarkdown files?
Thanks
The differences between .Rmarkdown and .Rmd is explained here. The most relevant quote being:
In this book, we usually mean .Rmd files when we say “R Markdown documents,” which are compiled to .html by default. However, there is another type of R Markdown document with the filename extension .Rmarkdown. Such R Markdown documents are compiled to Markdown documents with the extension .markdown, which will be processed by Hugo instead of Pandoc.
More specific differences are explained in the book linked above.
I'm trying to work out a way to post into confluence a R statistical program Markdown file. So far I have converted the markdown to PDF and imported that but I would like to be able to embed the markdown page directly.
Thanks!
If you want to use Markdown in Confluence, it's quite possible using my free Markdown for Confluence plugin. Get it here: https://bitbucket.org/dvdsmpsn/markdown-for-confluence/downloads
Alternatively, Atlassian have also written a Markdown Macro.
Hopefully, some of this will be applicable to R Markdown.
conflr package will allow you to publish to confluence from Rstudio or render and upload Rmd to confluence.
The new version of Rstudio (0.98.932) has many new options including knit to PDF. An article describing the new version has a comment from Dave that says:
...after installing rstudio 0.98.932 I don’t get the little dropdown menu
for knit-pdf or word when editing a .Rmd file.
I'm having the same issue. A helpful response was posted:
It might be that either:
a) You are not running R 3.0 (which is required for RMarkdown v2); or
b) You have a custom markdown renderer defined (markdownToHTML
option). You can check for this by executing:
getOption(“rstudio.markdownToHTML”)
That solved Dave's problem (b), but when I run that command I get NULL
> getOption("rstudio.markdownToHTML")
NULL
Which I assume means I don't have a custom markdown renderer defined. (Previously I did in a cusomized .Rprofile, but I removed that.) My R version is 3.1.0.
Am I misunderstanding the getOption command? Could something else be tripping up my Rstudio?
I have just installed the new version of RStudio (0.98.932), which prompted me to upgrade a couple of packages (I can't remember which, although I see I have knitr 1.6, markdown 0.7 and rmarkdown 0.2.46). At first I had the same problem; there was only a single 'knit' option on the tool bar. I managed to get the ability to knit to .pdf by adding the following to the head of my .Rmd file.
---
title: "Sample Document"
output: pdf_document
---
Having done that, I now find I do have a drop down menu with options to knit to HTML, PDF and word. There's also a little gear icon that provides access to the R Markdown document options that wasn't there before. I have no idea what the problem was but it seems OK now!
Adding on #nicholas response
This is also why I create new .Rmd documents through the RStudio gui
File > New File > R markdown.
This way the YAML header is populated correctly.