-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01_explore-libraries_jenny.R
72 lines (53 loc) · 1.74 KB
/
01_explore-libraries_jenny.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#' ---
#' output: github_document
#' ---
## 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
library(fs)
path_real(.Library)
#' 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))
#' devtools gives all information about the session at the time of compilation.
#' ...this is useful for debugging shared code
devtools::session_info()