In this post I am detailing my process for publishing the HTML output from an RMarkdown (RMD) file as a blog post on WordPress.
RMarkdown to WordPress
Install Packages
You will need to install the devtools package first as will install several packages from their GitHub repos.
install.packages("devtools")
Now lets get the needed packages from GitHub.You may also need the package RCurl as a dependency. As far as possible, install the binary version of the packages instead of the versions that need compiling.
devtools::install_github("duncantl/XMLRPC")
devtools::install_github("duncantl/RWordPress")
Configure Parameters
We will now load packages in the library and configure its parameters. Please note that there are no quote marks around the username. Also note that I am using an http version of the site. Using https may lead to SSL errors.
library(RWordPress)
options(WordPressLogin = c(username = 'password'),
WordpressURL = 'http://www.yoursite.com/xmlrpc.php')
postTitle = "Your Post Title"
fileName = "YourFileName.Rmd"
Publishig Your File
Now we will invoke the command to actually publish the output of the RMD file.
knit2wp(
input = fileName,
title = postTitle,
publish = FALSE,
action = "newPost"
)
This should do the trick. Note that this process creates a draft post in WordPress that you will need to publish using WordPress Dashboard.