3 min read

How to publish a package to CRAN

To publish a package on CRAN make sure it passes all checks. Simply run devtools::check

Here is a list of everything that is checked with this command.

I will semi-live-blog my debugging process here.

Here is a step by step of my debugging process

First check. Got a malformed Description file. Apparently the package description must end with a colon .. After that got some errors with the examples in the functions.

I had just added a cran-comments.md file to the repo. Now I need to remove it from the package build.

I’ll just go ahead and copy this .Rbuildignore from Thomas’ gganimate. Note that I left all the pkgdown and tests stuff. I will play with the usethis package once I clean up all errors and warnings here 6b3696a.

Next up… Dependencies.

I don’t know what I am doing here. It has never been clear to me where exactly to declare package dependencies… is it in Depend or Imports?… So let’s google.

Moved all to imports and the warning went away (still need to understand why). The issue with :: and ::: not being imported fom rlang got fixed by adding it to Suggests in DESCRIPTION [here 0d9d80]()

Ran usethis::use_package_doc() and it created a dsAppLayout-package.R file with the documentation of the package that I was lacking. Not sure if I need it later or not.

The fun part, fixing code

Added #' @import htmltools on top of the function box to fix the warning about the no visible global function definition for .... It works if I place it on any function documentation. Maybe I should be using importFrom instead.

Added documentation for all exported functions, like this:

#' Panel component for shiny panels layout
#'
#' @param head html for the panel header
#' @param body html tag list for panel body contents
#' @param show_footer include footer
#' @param footer footer contents
#' @param color color name as defined in custom css
#' @param id panel div id
#' @param collapsed panel starts as collapsed
#' @param width panel width in pixels
#' @param id panel div id
#'
#' @return None
#'
#' @examples
#' dsAppPanels()
#'
#' @export

Removed old .Rd files from old function that don’t exists anymore.

After fixing a bunch of parameters in the documentation it comes to this final warming

Fixed by adding testthat to Suggests in DESCRIPTION.

And… DONE!

Now I will add a proper README file. Added a screenshot of the package directly to the man/figures folder to show it in the README.

I read that you should test your package in at least 2 platforms. I am running now devtools::build_win() to run it on windows.

Now ready to [submit to CRAN]()… first try. Wait, I can use devtools::release() to do this automatically.

A couptle of questions… Ups…

Things I didn’t do before devtools::release():

  • devtools::spell_check()
  • devtools::check_rhub() checks your package in multiple platforms on http://r-hub.io

After answering the questions and a few minor tweaks I got:

Will update when I hear back from CRAN maintainers.

. . . . .

8 hours later. I got an email stating that I need to comply with the CRAN license template. Apparently it comes to deleting everything in the LICENSE and leaving only:

YEAR: 2019
COPYRIGHT HOLDER: Juan Pablo Marin Diaz

Note that I originally had an Organization field in the license, which does not comply with CRAN requirements. Resubmitted again…

. . .

18 days later after 4 resubmissions for simple things like dates and wrong license formatting my first package is on CRAN.

Enjoy

https://cran.r-project.org/web/packages/shinypanels/

https://github.com/datasketch/shinypanels