Skip to content

Instantly share code, notes, and snippets.

@hadley
Last active October 2, 2018 15:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadley/39ff26495b03744117974e8af0f26c71 to your computer and use it in GitHub Desktop.
Save hadley/39ff26495b03744117974e8af0f26c71 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(lubridate)
url1 <- "https://cran.rstudio.com/src/contrib/Meta/archive.rds"
url2 <- "https://cran.rstudio.com/src/contrib/Meta/current.rds"
if (!file.exists(basename(url1))) download.file(url1, basename(url1), quiet = TRUE)
if (!file.exists(basename(url2))) download.file(url2, basename(url2), quiet = TRUE)
archive <- readRDS("archive.rds")
current <- readRDS("current.rds")
archive_df <- archive %>%
bind_rows(.id = "package") %>%
bind_rows(rownames_to_column(current, "package"))
as_tibble()
daily <- archive_df %>%
mutate(submitted = floor_date(mtime, "week")) %>%
count(submitted) %>%
mutate(
year = year(submitted),
date = update(submitted, year = 2000)
)
daily %>%
filter(submitted > ymd("2017-01-01"))
daily %>%
filter(submitted > ymd("2005-01-01"), n < 5)
daily %>%
filter(submitted > ymd("2010-01-01"), n < 400) %>%
ggplot(aes(date, n)) +
geom_line() +
geom_point() +
facet_wrap(~year) +
scale_x_datetime(date_labels = "%b") +
labs(x = NULL, y = "Weekly downloads")
ggsave("accepted-cran.png", width = 8, height = 6, dpi = "screen")
@barryrowlingson
Copy link

Do lines 31/32 do anything or are they just debug remnants from testing with n<5 (whatever n is)? And should line 15 pipe into as_tibble(), otherwise line 16 does nothing. I guess it gets miraculously transformed to a tibble at some other point, or the rest of the code is happy as a data frame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment