Packages in non-standard repositories: What to do when submitting your own R package to CRAN

I’m currently finalising the submission of my packages FRK to CRAN. It depends on several packages, but not all of these are available on CRAN. Now, CRAN requires packages that are not available in mainstream repositories to be put into their own repositories, and their URLs then need to be specified in the Additional_respositories in the Description; see the package DESCRIPTION for an example.

If your aspiring CRAN package depends on a home-brewn package that will never make it to CRAN (e.g., a data package), then it needs to be put into its own repository. This seemed duanting to me until I came across this website here which explains how to construct your own repository on github pages. Basically the steps are as follows

  1. Create a new repo on github
  2. Create a repo of the same name using the instructions in the webpage
  3. Push the changes to the gh-pages branch

The last step is important; if these are not put in the gh-pages branch then these will not be visible by R CMD check.

One thing which took some time to figure out (thanks to Clint Shumack for helping me out) was that R CMD check was only checking for repos with http… unfortunately gh-pages enforces https. This, however, was because my R was outdated. As from R 3.3 R CMD check has full support for repositories which have to be accessed using https.

How do you know it is working correctly? When you do an R CMD check on your package you should get something which looks like

Suggests or Enhances not in mainstream repositories:
Availability using Additional_repositories specification:
dggrids yes

Publishing from R straight to

This post has been written in Rstudio using RMarkdown and then uploaded to using the knitr package of Yihui. The way in which this is done is excellently documented here and here. In this post I just wish to outline some minor observations and difficulties I encountered.


Installation of RWordPress, the required package for posting from R to WordPress, was pretty straightforward after installing the xml2-dev package on Ubuntu 14.04 using sudo apt-get install libxml2-dev:

                  repos = '',
                  type = 'source')

On CentOS the required package is libxml2-devel, however I did not manage to get R to post to on this platform (several HTML errors)

Publishing to

There are four steps to publish to

1. If you have two-stage verification set up then you have to login to and set an Application Password. All this does is generate a code which can be used by R or any other application for that matter, to bypass the two-stage authentication. I suggest you do this everytime you need to do a post and then delete the application password after each post.

2. Set your login options. This is done through

options(WordPressLogin = c(user = 'password'),
        WordPressURL = '')

One note about this, the label user is your actually username. So say your username is my_username then the function argument would be c(my_username = 'password'). The password is enclosed within the inverted commas and, if you have two-stage authentication, this would be the application password generated by The second argument then is Also please note that https needs to be used and not http.

3. Set the image base directory. Here I will follow Yihui’s recommendation and suggest the use of a Dropbox public folder for this, for example ~/Dropbox/Public/wpintro. The options are then set as follows

opts_knit$set(base.url = '',
              base.dir = '~/Dropbox/Public/wpintro/')

where 3038814 is replaced by your own user code. This can be found by simply uploading a file into the public folder, going on the Dropbox website, right clicking on the file and choosing Copy public link….

I show this works in principle by plotting the following figure:

x <- seq(0,100,by=0.1)
y <- sin(2*pi*0.1*x)

plot of chunk unnamed-chunk-4

4. I had a small problem with paths which I haven’t resolved yet. In particular, I only manage to get the figures in the right subdirectory if I change the path to ~/Dropbox/Public/wpintro/ and run knitr from this location. This is not much of a problem, so I will keep it at that for now. The final commands you need to run therefore are

        title = 'My Post Title',
        publish = FALSE,
        shortcode = TRUE)

The publish=FALSE flag allows you to first review the post on before publishing it.