Last active
December 9, 2020 08:23
-
-
Save verajosemanuel/5779b04c4a5d4c5713504ac60b44624d to your computer and use it in GitHub Desktop.
detect #github #packages in #R #library
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 characters
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