Post blogs directly from R with RWordpress

Loading your R markdown documents onto your wordpress blog is super easy, but at the moment can be a little frustrating if you follow the posts you find on google at the moment.

Most likely the easiest way to publish your R work is to use the knitr and RWordPress packages. However, most blogs will tell you to install RWordPress from cran using install.packages(). Frustratingly this isn’t available at the moment. The Scripts and Statistics blog pointed out that the package is still available on github.

install.packages("devtools")
install.packages("RCurl")
install.packages("XML")
devtools:::install_github("duncantl/XMLRPC")
devtools:::install_github("duncantl/RWordPress")

You can then load the RWordPress package and set the correct options to your website. The options code is given in a blog published on R-Bloggers, but it has a capital P (Word[P/p]ressLogin) syntax error that doesn’t result in an error message.

library(RWordPress)
options(WordpressLogin=c(user_name="password"),
        WordpressURL="http://your_blog.com/xmlrpc.php")

Simply replace user_name and password with the login of your wordpress back-end login. And replace your_blog with the name of your website.

To push a finalised R markdown document to wordpress:

knit2wp("Blog_post_name.Rmd", 
        title = "Title")

Hope that works. Best,

Jiddu

Leave a Reply

Your email address will not be published. Required fields are marked *