Created
February 21, 2018 22:27
-
-
Save tomhopper/14900d301236799ef4f44d7853efb6e1 to your computer and use it in GitHub Desktop.
Revisions
-
tomhopper created this gist
Feb 21, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ #' @description Returns a list of all packages on CRAN #' @param columns_list A character vector of field names to return from package DESCRIPTION files #' @return A data frame containing all packages on CRAN #' @details Function modified from StackOverflow answer at \url{https://stackoverflow.com/a/11561793}. #' @importFrom magrittr %>% #' @importFrom tibble as.tibble #' @importFrom dplyr select_ getCRANPackages <- function(columns_list = c("Package", "Title", "Version", "Date", "Published", "URL")) { contrib.url(getOption("repos")["CRAN"], "source") description <- sprintf("%s/web/packages/packages.rds", getOption("repos")["CRAN"]) con <- if(substring(description, 1L, 7L) == "file://") { file(description, "rb") } else { url(description, "rb") } on.exit(close(con)) db <- readRDS(gzcon(con)) rownames(db) <- NULL db <- db %>% as.tibble() %>% select_(.dots = columns_list) return(db) }