← Back Home

My first CRAN package

  1. rstats
  2. package
  3. development
  4. CRAN

Thanks, your package is on its way to CRAN.

Introduction

I am really excited to announce (12 days late) that lisa is on CRAN, my first R package available on the Comprehensive R Archive Network! This was a pretty big deal for me because I have wanted to submit something to CRAN for a couple of years now.

Anyway, lisa is a color palette pacakge, it provides R users with 128 color palettes based on artwork from the worlds greatest artists. These palettes were made by designers, artists, museum curators, and masters of color theory. You can view them all at colorlisa, a beautiful website created by Ryan McGuire.

Package Details

The lisa package contains a list of palettes, a dataset containing palette information and a function for calling and modifying palettes:

str(lisa[1])
#> List of 1
#>  $ JosefAlbers: 'lisa_palette' chr [1:5] "#D77186" "#61A2DA" "#6CB7DA" "#b5b5b3" ...
#>   ..- attr(*, "name")= chr "JosefAlbers"
#>   ..- attr(*, "work")= chr "Adobe (Variant): Luminous Day"

head(artwork)
#>              artist          palette                              work
#> 1      Josef Albers      JosefAlbers     Adobe (Variant): Luminous Day
#> 2      Josef Albers    JosefAlbers_1 Homage to the Square (La Tehuana)
#> 3 Gretchen Albrecht GretchenAlbrecht                      Golden Cloud
#> 4       Billy Apple       BillyApple                           Rainbow
#> 5       Per Arnoldi       PerArnoldi                              Spar
#> 6      Milton Avery      MiltonAvery        Bicycle Rider By The Loire

lisa_palette("JosefAlbers", 2, "discrete")
#> [1] "#D77186" "#61A2DA"

There are also two S3 methods, one for printing and one for plotting objects of class lisa_palette:

class(lisa$`Jean-MichelBasquiat`)
#> [1] "lisa_palette" "character"

plot(lisa$`Jean-MichelBasquiat`)

That’s pretty much it! Currently, ggplot2 usage requires something like scale_color_manual. I’ve thought about including custom ggplot2 color functions, similiar to what paletteer does but have put this on hold, maybe the next release.

library(ggplot2)

ggplot(mtcars, aes(mpg, disp)) + 
  geom_point(aes(col = factor(gear)), size = 3) + 
  scale_color_manual(values = lisa$`Jean-MichelBasquiat`) + 
  theme_bw()

CRAN Submission Process

I submitted the package, got rejected with correction comments, resubmitted, and the package was on CRAN the next day. This all took a total of 5 days. My first submission was rejected because I had redundant wording and didn’t include a reference to colorlisa. Redundant wording was things like “This is an R package…”. This type of wording in the description is considered redundant because the user already knows its an R package.

Takeaways

If you’re like me and want to submit a package to CRAN for the first time I would recommend a couple things:

  1. devtools and usethis are necessary! They actually aren’t but they make the development process much easier and enjoyable. I submitted my pacakge using devtools::release which introduced me to a whole bunch of checks that I hadn’t thought of. For example, spell check, rhub, and more.
  2. Test your code with testthat, check coverage with covr, continously integrate your code with services like travis-ci and appveyor.
  3. When possible, make your package lightweight, the less dependencies the better.
  4. Tweet about your package! No one will use it if they don’t know it exists.
  5. Read relevant sections of https://r-pkgs.org/