Sunday, July 14, 2013

Blogging with R Markdown



This is just an experiment on using the R Markdown facility in RStudio to obtain a simpler blogging workflow for Blogger.

Step 1. Create a new folder tree

It's a good practice to create an dedicated folder tree for the post, after all, is just like starting a new small project.

Create any extra folder you think you might need, for instance an image folder to put any image needed that is not an R plot (those will be automatically saved in a figure folder).

alt text

Step 2. Write your post in R Markdown

!!!This is the just the R Markdown template!!!

This is an R Markdown document. Markdown is a simple formatting syntax for authoring web pages (click the MD toolbar button for help on Markdown).

When you click the Knit HTML button a web page 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:

##      speed           dist    
##  Min.   : 4.0   Min.   :  2  
##  1st Qu.:12.0   1st Qu.: 26  
##  Median :15.0   Median : 36  
##  Mean   :15.4   Mean   : 43  
##  3rd Qu.:19.0   3rd Qu.: 56  
##  Max.   :25.0   Max.   :120

You can also embed plots, for example:


plot of chunk unnamed-chunk-2

Step 3. Knit HTML

Press the Knit HTML button and a Preview HTML window will appear so the result can be checked.

alt text

By now the folder tree has new files and folders.

alt text

Step 4. Copy HTML into Blogger

Open in Editor the resulting HTML file and copy all of it into Blogger.

No comments:

Post a Comment