Get all previous versions of packages in RStudio Package Manager

Hi all,

As the question states - how do I programmatically in R retrieve all versions of all packages currently in a repo in RStudio Package Manager, and their package tar.gtz-bundle URLs?

Thank you

Since a repository hosted in RStudio Package Manager is just a standard R repository, you can use standard R functions to achieve this task.

Specifically, use available.packages() to list all packages, and their versions, in a repo. This function returns a matrix with columns for (among others):

  • package
  • version
  • repo URL
library(dplyr)
repos <- "https://packagemanager.rstudio.com/cran/latest"
pkgs <- available.packages(repos = repos) %>% head()
pkgs
            Package       Version  Priority Depends                         
A3          "A3"          "1.0.0"  NA       "R (>= 2.15.0), xtable, pbapply"
AATtools    "AATtools"    "0.0.1"  NA       "R (>= 3.6.0)"                  
ABACUS      "ABACUS"      "1.0.0"  NA       "R (>= 3.1.0)"                  
ABC.RAP     "ABC.RAP"     "0.9.0"  NA       "R (>= 3.1.0)"                  
ABCanalysis "ABCanalysis" "1.2.1"  NA       "R (>= 2.10)"                   
ABCoptim    "ABCoptim"    "0.15.0" NA       NA                              
            Imports                                LinkingTo Suggests                               Enhances
A3          NA                                     NA        "randomForest, e1071"                  NA      
AATtools    "magrittr, dplyr, doParallel, foreach" NA        NA                                     NA      
ABACUS      "ggplot2 (>= 3.1.0), shiny (>= 1.3.1)" NA        "rmarkdown (>= 1.13), knitr (>= 1.22)" NA      
ABC.RAP     "graphics, stats, utils"               NA        "knitr, rmarkdown"                     NA      
ABCanalysis "plotrix"                              NA        NA                                     NA      
ABCoptim    "Rcpp, graphics, stats, utils"         "Rcpp"    "testthat, covr"                       NA      
            License              License_is_FOSS License_restricts_use OS_type Archs MD5sum NeedsCompilation File
A3          "GPL (>= 2)"         NA              NA                    NA      NA    NA     "no"             NA  
AATtools    "GPL-3"              NA              NA                    NA      NA    NA     "no"             NA  
ABACUS      "GPL-3"              NA              NA                    NA      NA    NA     "no"             NA  
ABC.RAP     "GPL-3"              NA              NA                    NA      NA    NA     "no"             NA  
ABCanalysis "GPL-3"              NA              NA                    NA      NA    NA     "no"             NA  
ABCoptim    "MIT + file LICENSE" NA              NA                    NA      NA    NA     "yes"            NA  
            Repository                                                  
A3          "https://packagemanager.rstudio.com/cran/latest/src/contrib"
AATtools    "https://packagemanager.rstudio.com/cran/latest/src/contrib"
ABACUS      "https://packagemanager.rstudio.com/cran/latest/src/contrib"
ABC.RAP     "https://packagemanager.rstudio.com/cran/latest/src/contrib"
ABCanalysis "https://packagemanager.rstudio.com/cran/latest/src/contrib"
ABCoptim    "https://packagemanager.rstudio.com/cran/latest/src/contrib"

Now you can construct the URL for any specific package, e.g:

pkgs %>% 
  as_tibble() %>% 
  mutate(
    url = paste0(Repository, "/", Package, "_", Version, ".tar.gz")
  ) %>% 
  select(url)
# A tibble: 6 x 1
  url                                                                                
  <chr>                                                                              
1 https://packagemanager.rstudio.com/cran/latest/src/contrib/A3_1.0.0.tar.gz         
2 https://packagemanager.rstudio.com/cran/latest/src/contrib/AATtools_0.0.1.tar.gz   
3 https://packagemanager.rstudio.com/cran/latest/src/contrib/ABACUS_1.0.0.tar.gz     
4 https://packagemanager.rstudio.com/cran/latest/src/contrib/ABC.RAP_0.9.0.tar.gz    
5 https://packagemanager.rstudio.com/cran/latest/src/contrib/ABCanalysis_1.2.1.tar.gz
6 https://packagemanager.rstudio.com/cran/latest/src/contrib/ABCoptim_0.15.0.tar.gz 

Thanks, but I need all versions, e.g. a line for each archived version for each package.

Thanks again.
/J