Created
October 4, 2018 16:47
-
-
Save jimhester/71d074149a732c83f9d881c8d33efbad to your computer and use it in GitHub Desktop.
wtf-1
This file contains 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
#' Which libraries does R search for packages? | |
# try .libPaths(), .Library | |
#' Installed packages | |
## use installed.packages() to get all installed packages | |
## if you like working with data frame or tibble, make it so right away! | |
## remember to use View() or similar to inspect | |
## how many packages? | |
#' Exploring the packages | |
## count some things! inspiration | |
## * tabulate by LibPath, Priority, or both | |
## * what proportion need compilation? | |
## * how break down re: version of R they were built on | |
## for tidyverts, here are some useful patterns | |
# data %>% count(var) | |
# data %>% count(var1, var2) | |
# data %>% count(var) %>% mutate(prop = n / sum(n)) | |
#' Reflections | |
## reflect on ^^ and make a few notes to yourself; inspiration | |
## * does the number of base + recommended packages make sense to you? | |
## * how does the result of .libPaths() relate to the result of .Library? | |
#' Going further | |
## if you have time to do more ... | |
## is every package in .Library either base or recommended? | |
## study package naming style (all lower case, contains '.', etc) | |
## use `fields` argument to installed.packages() to get more info and use it! |
This file contains 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
## how jenny might do this in a first exploration | |
## purposely leaving a few things to change later! | |
#' Which libraries does R search for packages? | |
.libPaths() | |
## let's confirm the second element is, in fact, the default library | |
.Library | |
identical(.Library, .libPaths()[2]) | |
## Huh? Maybe this is an symbolic link issue? | |
library(fs) | |
identical(path_real(.Library), path_real(.libPaths()[2])) | |
#' Installed packages | |
library(tidyverse) | |
ipt <- installed.packages() %>% | |
as_tibble() | |
## how many packages? | |
nrow(ipt) | |
#' Exploring the packages | |
## count some things! inspiration | |
## * tabulate by LibPath, Priority, or both | |
ipt %>% | |
count(LibPath, Priority) | |
## * what proportion need compilation? | |
ipt %>% | |
count(NeedsCompilation) %>% | |
mutate(prop = n / sum(n)) | |
## * how break down re: version of R they were built on | |
ipt %>% | |
count(Built) %>% | |
mutate(prop = n / sum(n)) | |
#' Reflections | |
## reflect on ^^ and make a few notes to yourself; inspiration | |
## * does the number of base + recommended packages make sense to you? | |
## * how does the result of .libPaths() relate to the result of .Library? | |
#' Going further | |
## if you have time to do more ... | |
## is every package in .Library either base or recommended? | |
all_default_pkgs <- list.files(.Library) | |
all_br_pkgs <- ipt %>% | |
filter(Priority %in% c("base", "recommended")) %>% | |
pull(Package) | |
setdiff(all_default_pkgs, all_br_pkgs) | |
## study package naming style (all lower case, contains '.', etc | |
## use `fields` argument to installed.packages() to get more info and use it! | |
ipt2 <- installed.packages(fields = "URL") %>% | |
as_tibble() | |
ipt2 %>% | |
mutate(github = grepl("github", URL)) %>% | |
count(github) %>% | |
mutate(prop = n / sum(n)) |
This file contains 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
#' Which libraries does R search for packages? | |
#' Installed packages | |
## use installed.packages() to get all installed packages | |
## how many packages? | |
#' Exploring the packages | |
## count some things! inspiration | |
## * tabulate by LibPath, Priority, or both | |
## * what proportion need compilation? | |
## * how break down re: version of R they were built on | |
#' Reflections | |
## reflect on ^^ and make a few notes to yourself; inspiration | |
## * does the number of base + recommended packages make sense to you? | |
## * how does the result of .libPaths() relate to the result of .Library? | |
#' Going further | |
## if you have time to do more ... | |
## is every package in .Library either base or recommended? | |
## study package naming style (all lower case, contains '.', etc | |
## use `fields` argument to installed.packages() to get more info and use it! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment