Skip to content

Using knitr to publish R syntax on Baylor’s WordPress/Edublog Posts

If you want to incorporate R syntax and output into your posts, it can be a little tricky. If you use knitr, this process can be made a little easier.

  1. Write your blog post in a Markdown document that includes your R syntax, save it as a .Rmd file (e.g., Post.Rmd)
  2. Install the markdown and knitr packages from your favorite CRAN mirror.

install.packages('markdown')
install.packages('knitr')
  1. Install the RWordPress package from omegahat.org

install.packages('RWordPress', repos = 'http://www.omegahat.org/R', type = 'source')
  1. Use R to submit your .Rmd file as your post

# Log into your web page via R
library(RWordPress)
options(WordPressLogin = c("First_Last" = 'password'), WordPressURL = 'https://blogs.baylor.edu/first_last/TO/xmlrpc.php')
# have knitr compile your Rmd file and upload it to your web page
library(knitr)
knit2wp('Post.Rmd', title = 'Post Title')
Published inR