Replication scripts can be posted on a number of wesbites. Below are snippets that can be used to post on a Github repository or posted directly on the Wordpress platform.
Below we use the RWordPress
package developed by Duncan Temple Lang (here). It allows users to send an already compiled .html file to a Wordpress website as a blog post by entering your credentials and blog post-related fields.
if (!require('RWordPress')) { # RWordPress and XMLRPC need to be installed from Github devtools::install_github(c("duncantl/XMLRPC", "duncantl/RWordPress")) } library(knitr) library(RWordPress) library(readr)
# File (include full path if the file is not contained in current directory) html.file = "20190717_Replication.html" text = paste(read_lines(html.file, skip = 18), collapse = "\n") # Set config options (fill in 'username' and 'password' fields) options(WordpressLogin = c(username = 'password'), WordpressURL = 'http://www.mywebsite.nyc/xmlrpc.php') # Post content/html code goes in 'description' # Set 'title' to blog post (in this case paper) title # Set 'publish = FALSE' to create draft post, 'TRUE' to publish post directly newPost( list(description = text, categories = c("Replication"), title = "Replication: Humphreys, Sanchez de la Sierra, van der Windt (2019)" ), publish = FALSE)
See ?RWordPress
for further documentation on RWordPress
package functions.
Compiled .md
files will display nicely once they are uploaded to Github. This can be done by editing the output field in the .Rmd YAML:
output: rmarkdown::github_document
or, alternatively, setting keep_md = TRUE
.
output: html_document: keep_md: true
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.