This is an R Markdown document that will end up as a wordpress post, describing the process of publishing to WordPress directly from an R Markdown document in RStudio. You need a few things in order to get started, but they are easy to install. The biggest thing needed is the RWordPress package, which is not included in the standard repositories, and it is no longer available from the omegahat website. Don't worry, it can still be accessed from GITHUB. So we need two things:1- The dependencies for RWordPress (namely RCurl, XML and XMLRPC)
2- A way to install packages directly from GITHUB (namely, devtools)(Thanks to Koehlern at “Scripts and Statistics” for this workaround).Let's get cracking. Simply run this to get the required packages:
install.packages("devtools") install.packages("RCurl") devtools:::install_github("duncantl/XMLRPC") devtools:::install_github("duncantl/RWordPress")
Great. Now run the following, replacing with your values for 'user', 'password', 'wordpressurl', 'yourmarkdownfile', and 'desired post title':
library(RWordPress) options(WordPressLogin=c(user='password'),WordpressURL='https://user.wordpress.com/xmlrpc.php') library(knitr) knit2wp('yourmarkdownfile.Rmd',title="desired post title")
If you get errors, check carefully for typos. Commands can be case-sensitive. If all went well, the RMarkdown document you described should be posted to your wordpress blog! I'll check mine right now. Code can be found on Github.