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
repos <- ""
pkgs <- available.packages(repos = repos) %>% head()
            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  
A3          ""
AATtools    ""
ABACUS      ""
ABC.RAP     ""
ABCanalysis ""
ABCoptim    ""

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

pkgs %>% 
  as_tibble() %>% 
    url = paste0(Repository, "/", Package, "_", Version, ".tar.gz")
  ) %>% 
# A tibble: 6 x 1

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

Thanks again.

1 Like