SHARE
TWEET

Untitled

a guest Jul 17th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library(dplyr)
  2. library(ggplot2)
  3. library(lubridate)
  4. library(cranlogs)
  5. library(hrbrthemes)
  6.  
  7. dl <-
  8.   cran_downloads(
  9.     package = c("bomrang", "GSODR", "getCRUCLdata", "nasapower", "hagis"),
  10.     from = "2016-09-01"
  11.   )
  12.  
  13. plot_data <-
  14.   dl %>%
  15.   mutate(date = as.Date(date)) %>%
  16.   mutate(ym = format(date, '%Y-%m')) %>%
  17.   mutate(ym = ymd(ym, truncated = 1))
  18.  
  19. ggplot(plot_data, aes(x = date, y = count, group = package)) +
  20.   geom_area(aes(colour = package,
  21.                 fill = package)) +
  22.   guides(fill = FALSE, color = FALSE) +
  23.   xlab("Year - Month") +
  24.   ylab("Daily Downloads") +
  25.   labs(
  26.     title = "R package daily downloads",
  27.     caption = paste0(
  28.       "There have been ",
  29.       summarise(dl, sum(count)),
  30.       " total downloads.\n",
  31.       "Source: RStudio Cloud Server CRAN Mirror"
  32.     )
  33.   ) +
  34.   scale_fill_ft() +
  35.   scale_colour_ft() +
  36.   facet_wrap(package ~ ., scales = "free_y") +
  37.   theme_ft_rc()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top