New post test
Posted on March 18, 2017
An initial example using knitpost
R script, see post by JFisher, for quickly converting R-markdown (*.rmd)
into markdown (*.md)
with the associated images and such…
based on KnitPost
see http://jfisher-usgs.github.io/r/2012/07/03/knitr-jekyll/
The knitr package provides an easy way to embed R code in a Jekyll-Bootstrap blog post. The only required input is an R Markdown source file. The name of the source file used to generate this post is 2012-07-03-knitr-jekyll.Rmd, available here. Steps taken to build this post are as follows:
Step 1
Create a Jekyll-Boostrap blog if you don’t already have one. A brief tutorial on building this blog is available here.
Step 2
Open the R Console and process the source file:
KnitPost <- function(input, base.url = "/") {
require(knitr)
opts_knit$set(base.url = base.url)
fig.path <- paste0("figs/", sub(".Rmd$", "", basename(input)), "/")
opts_chunk$set(fig.path = fig.path)
opts_chunk$set(fig.cap = "center")
render_jekyll()
knit(input, envir = parent.frame())
}
KnitPost("2012-07-03-knitr-jekyll.Rmd")
Step 3
Move the resulting image folder 2012-07-03-knitr-jekyll and Markdown file 2012-07-03-knitr-jekyll.md to the local jfisher-usgs.github.com git repository. The KnitPost function assumes that the image folder will be placed in a figs folder located at the root of the repository.
Step 4
Add the following CSS code to the /assets/themes/twitter-2.0/css/bootstrap.min.css file to center images:
[alt=center] {
display: block;
margin: auto;
}
Thats it.
Here are a few examples of embedding R code:
Figure 1-1: Caption
Figure 2-1: Caption
And dont forget your session information for proper reproducible research.
R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
Including Plots
You can also embed plots, for example:
Note that the echo = FALSE
parameter was added to the code chunk to prevent printing of the R code that generated the plot.