Writing wordpress blog posts in R markdown

R markdown makes writing reproducible documents a breeze. Its human readable so you can learn to use it fast and you can export documents as html, word, pdf, and markdown for wordpress!

Using R markdown to write wordpress blog posts is easy. First you have to enable markdown down on your blog. To do this you go to settings and then click writing and check the box that says markdown. Then you just need to change the output of your R Markdown document to an md_document and the variant to markdown_phpextra+backtick_code_blocks

The firts chunck of code in your Rmarkdown document will look like this:

title: "Wordpress Post"
author: "Your Name"
date: "July 4, 2015"
variant: markdown_phpextra+backtick_code_blocks

Thats it! You can copy and paste the output of your R markdown document into the text editor for your posts and it will generate a clean output!

What you can put in your post is nearly endless. Here are some examples to whet your appetite.

You can add equations:

α2 + b2 = c2

You can add tables:

Label Defining Characteristics Logan Phillips Washington Yuma Kit Carson
Wind Pollinated Crops Anemophilous or self-fertilizing plants 63% 72% 40% 72% 35%
Animal Pollinated Crops Entomophilous plants 11% <1% 5% 2% <1%
Grassland and Pasture Non-crop grasses dominate 20% 23% 45% 15% 34%
Forest and Shrubland Non-grasses dominate 4% <1% <1% <1% <1%
Developed Land Modified non-agricultural land 1% 3% 4% 10% 31%
Water and Wetlands Open water and permanent wetlands 1% <1% <1% <1% <1%

And of course code!

<br /># Animating a 3d plot
frames <- 720

for(i in 1:frames){
# creating a name for each plot file with leading zeros
if (i < 10) {name = paste('000',i,'3dplot.png',sep='')}
if (i = 10) {name = paste('00',i,'3dplot.png', sep='')}
if (i >= 100) {name = paste('0', i,'3dplot.png', sep='')}

#saves the plot as a .png file in the working directory
png(filename = name)
scatterplot3d(gis.mds3.pts, angle = 45 + i , color = env.data$color,pch = 20, cex.symbols = 2 )

See Markdown Basics for more information on getting started with with R Markdown.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s