Load R packages needed to get and visualize the data

# devtools::install_github("metacran/cranlogs") #https://cranlogs.r-pkg.org/
library(cranlogs)
library(data.table)
library(ggplot2)
library(plotly)
library(hrbrthemes)
# extrafont::loadfonts()

Set a range of dates and names of the packages to track

date1 <- "2015-01-01"
# Today
date2 <- Sys.Date() 
# Start of this month
date2 <- as.Date(format(date2, "%Y-%m-01"))
# End of last month
date2 <- date2 - 1
P <- c("funtimes", "lawstat", "snowboot")
D <- cran_downloads(from = date1, to = date2, packages = P)
D <- setDT(D)
setnames(D, "package", "Package")

Aggregate by month

d <- D[, .(Count = sum(count)), by = .(Year = year(date), 
                                       Month = months(date),
                                       Package)]
# Create the date variable for plotting
d <- d[, ':='(
    Date = as.Date(paste0(Year, "-", Month, "-01"), format = "%Y-%B-%d")
)]

Sums

d %>% 
  group_by(Package) %>% 
  summarise(Total = sum(Count))
## # A tibble: 3 × 2
##   Package   Total
##   <chr>     <dbl>
## 1 funtimes  67993
## 2 lawstat  409561
## 3 snowboot  29702

Plot data using ggplot2

p <- ggplot(d, aes(x = Date, y = Count, group = Package, colour = Package)) +
    geom_line(size = 1.2) +
    xlab("") + ylab("Total monthly downloads") + 
    ggtitle(paste0("Downloads of the R packages from CRAN (from ", date1, " to ", date2, ")")) +
    theme_ipsum_pub() + 
    theme(plot.title = element_text(size = 12))

Make the plot interactive using plotly

ggplotly(p)