Skip to content

Instantly share code, notes, and snippets.

@verajosemanuel
Last active December 9, 2020 08:23
Show Gist options
  • Save verajosemanuel/5779b04c4a5d4c5713504ac60b44624d to your computer and use it in GitHub Desktop.
Save verajosemanuel/5779b04c4a5d4c5713504ac60b44624d to your computer and use it in GitHub Desktop.
detect #github #packages in #R #library
library(tidyverse)
allmypackages <- as.data.frame(installed.packages())
allmypackages <- allmypackages %>%
filter(Priority != "base" | is.na(Priority)) %>%
select(-c(Enhances:MD5sum, LinkingTo:Suggests)) %>%
droplevels()
package_source <- function(pkg){
x <- as.character(packageDescription(pkg)$Repository)
if (length(x)==0) {
y <- as.character(packageDescription(pkg)$GithubRepo)
z <- as.character(packageDescription(pkg)$GithubUsername)
if (length(y)==0) {
return("Other")
} else {
return(str_c("GitHub repo = ", z, "/", y))
}
} else {
return(x)
}
}
df <- sapply(allmypackages$Package, package_source)
df %>% .[matches("[GitHub]", vars=.)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment