Skip to content

Instantly share code, notes, and snippets.

@pat-s
Last active May 16, 2022 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pat-s/0451f66ff35635ff054deaee1440617d to your computer and use it in GitHub Desktop.
Save pat-s/0451f66ff35635ff054deaee1440617d to your computer and use it in GitHub Desktop.
Collects all mlr3 packages updates in the last quarter
library(tidyverse)
library(htmltab)
library(lubridate)
library(pkgsearch)
list_repos = httr::content(httr::GET("https://api.github.com/orgs/mlr-org/repos?per_page=100"))
list_repos_v = unlist(lapply(list_repos, function(x) x$name))
repos_mlr3 = grep("mlr3", list_repos_v, value = TRUE)
# add non-mlr3 repos
repos_mlr3 = c(repos_mlr3, "paradox", "miesmuschel", "bbotk")
# remove some repos
repos_mlr3_sub = setdiff(repos_mlr3, c(
"mlr3learners.template", "mlr3book", "mlr3misc",
"mlr3orga", "mlr3survival", "mlr3fda", "mlr3temporal", "mlr3ordinal",
"mlr3keras", "miesmuschel", "mlr3tuningsets"
))
# updated CRAN packages in the last 3 months
updated_last_quarter = htmltab::htmltab("https://cran.r-project.org/web/packages/available_packages_by_date.html",
which = 1, encoding = "UTF-8") %>%
filter(Package %in% repos_mlr3_sub) %>%
filter(Date >= lubridate::today() - lubridate::days(90))
updated_pkgs_last_quarter = sort(updated_last_quarter$Package)
titles = updated_last_quarter %>%
arrange(Package) %>%
pull(Title)
updated_last_quarter_pkg = updated_last_quarter %>%
pull(Package)
news_pkgs = lapply(
sort(updated_last_quarter_pkg),
function(x) head(readLines(sprintf("https://raw.githubusercontent.com/mlr-org/%s/main/NEWS.md", x)), 30)
)
url_pkgs = mlr3misc::map_chr(sort(updated_pkgs_last_quarter), function(x) {
paste0("https://github.com/mlr-org/", x)
})
news_pkgs_mod = mlr3misc::pmap(list(titles, news_pkgs, updated_pkgs_last_quarter, url_pkgs),
function(.title, .news, .names, .url) {
# append pkg titles
.news = append(.news, c(paste0("**Description: ", .title, "**"), ""), after = 2)
# append URLs to title
.news[1] = paste0(.news[1], " - ", .url)
return(.news)
}
)
news_pkgs = news_pkgs_mod %>%
reduce(c)
writeLines(news_pkgs, "news-pkgs.md")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment