pacman Ver 0.4.1 Release

It was just over a year ago that Dason Kurkiewicz and I released pacman to CRAN.  We have been developing the package on GitHub in the past 14 months and are pleased to announce these changes have made their way to CRAN in version 0.4.1.


What Does pacman Do?

pacman is an R package management tool that combines the functionality of base library related functions into intuitively named functions. This package is ideally added to .Rprofile to increase workflow by reducing time recalling obscurely named functions, reducing code and integrating functionality of base functions to simultaneously perform multiple actions.

We really wished people would use pacman to share code (blog posts and help list/boards).  The reason is selfish.  Often one is trying out code and the poster has ten new packages in use that we don’t have.  This means we have to stop the act of trying out the poster’s code to install the packages being used.  To add injury to insult multiple library calls makes the script less readable.

Sing it with us…

Imagine there’s no install.packages
It’s easy if you try
No multiple library calls
Above us only sky
Imagine all the coders
Using pacman today…

Skip to the bottom where we demo what this coders utopia looks like.

What’s New in Version 0.4.1?

Here are a few of the most notable highlights.

  • Support for Bioconductor packages added compiments of Keith Hughitt.
  • p_boot added to generate a string for the standard pacman script header that, when added to scripts, will ensure pacman is installed before attempting to use it. pacman will attempt to copy this string (standard script header) to the clipboard for easy cut and paste.
  • p_install_version_gh and p_load_current_gh added as partners to p_install_version for GitHub packages. Thanks to Steve Simpson for this.

Example Use

We will examine pacman‘s popularity in the last 14 months.  We implore the readers to make the package used even more by using it in scripts posted online.

This script uses pacman to allow the user to check for, install, and load the four required packages all with two easy lines of code.  The first line (compliments of p_boot) just makes sure pacman is installed.  The later checks for, installs, and loads the packages.  It’s pretty nice to just run a script isn’t it?

if (!require("pacman")) install.packages("pacman")
pacman::p_load(cranlogs, dplyr, ggplot2, scales)

package <- "pacman"
color <- "#26B8A6"
hjust <- -.069
start <- "2015-02-01"

lvls <- format(seq(as.Date(start), to = Sys.Date(), by = "month"), format = "%b %y")

dat <- cran_downloads(packages=package, from=start, to = Sys.Date()) %>%
    tbl_df() %>%
    select(-package) %>%
      date = as.POSIXct(date),
      month = factor(format(date, format = "%b %y"), levels = lvls)
    ) %>%
    na.omit() %>%
    rename(timestamp = date)

aggregated <- dat %>%
  group_by(month) %>%
  summarize(n=sum(count), mean=mean(count), sd=sd(count)) %>%
      filter(n > 0)

aggregated  %>%
      ggplot(aes(month, n, group=1)) +
          geom_path(size=4, color=color) + 
          geom_point(size=8, color=color) +    
          geom_point(size=3, color="white") + 
          theme_bw() +
          #ggplot2::annotate("segment", x=-Inf, xend=-Inf, y=-Inf, yend=Inf, color="grey70") +
              x = NULL, #"Year-Month", 
              y = NULL, #"Downloads", 
              title = sprintf("Monthly RStudio CRAN Downloads for %s", package)
          ) +
              panel.grid.major.x = element_blank(),
              panel.border = element_blank(), 
              axis.line = element_line(),
              axis.ticks.x = element_line(color='grey70'),
              axis.ticks.y = element_blank(),
              plot.title = element_text(hjust = hjust, face="bold", color='grey50')
          ) + 
              expand = c(0, 0), 
              limits = c(0, max(aggregated$n)*1.15), 
              labels = comma 



The script is customizable for any package.  Here we view a few more packages’ usage (some of the ones I’ve been enjoying as of late). Oh and you can download all of these packages via:

if (!require("pacman")) install.packages("pacman")
pacman::p_load(googleformr, googlesheets, dplyr, text2vec, waffle, colourlovers, curl, plotly)












About tylerrinker

Data Scientist, open-source developer , #rstats enthusiast, #dataviz geek, and #nlp buff
This entry was posted in Uncategorized, work flow and tagged , , , , , . Bookmark the permalink.

4 Responses to pacman Ver 0.4.1 Release

  1. Pingback: pacman Ver 0.4.1 Release – Mubashir Qasim

  2. Sam Firke says:

    I love this package and the new release looks great. The p_boot() text is clever, I was simply using library(pacman), which choked for those not yet using the package.

    I enjoy beginning every R script with the same first line – followed by many fewer lines as I efficiently p_load other packages!

  3. Pingback: pacman Ver 0.4.1 Release | r software hub

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s