forked from pharmaR/pharmapkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
122 lines (91 loc) · 2.41 KB
/
README.Rmd
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
options(
cli.ansi = FALSE,
cli.dynamic = FALSE
)
```
# pharmapkgs
<!-- badges: start -->
<!-- badges: end -->
The goal of `{pharmapkgs}` is to facilitate the interfacing with CRAN-like
repositories of validated packages with risk metrics.
## Installation
_using `devtools`_
```r
# install.packages("devtools")
devtools::install_github("pharmaR/pharmapkgs")
```
_using `pak`_
```r
# install.packages("pak")
pak::pkg_install("github::pharmaR/pharmapkgs")
```
## Bare Bones Demo
All available packages from local repository.
```{r}
library(pharmapkgs)
# local snapshot, bundled with pharmapkgs
repo <- bundled_repos("ubuntu-22.04")
available.packages(repos = repo, fields = risk_fields(repo)) |>
tibble::as_tibble()
```
Packages filtered using `{riskmetrics}` criteria.
```{r}
# Fancy criteria.
my_filters <- risk_filter(
ReverseDependencies < 0.5,
HasNews == "1",
RemoteChecks > 0.9
)
# Apply filter when inspecting packages
tibble::as_tibble(available.packages(
repos = repo,
fields = risk_fields(repo),
filters = my_filters
))
```
## Filtered Available Packages Workflow
Configure a session to leverage a bundled repo.
```{r}
repo <- bundled_repos("ubuntu-22.04")
options(
# importantly, repo is called CRAN such that pak doesn't insert a CRAN mirror
# awaiting feature r-lib/pak#637
repos = c(CRAN = repo)
)
nrow(available.packages())
```
We can provide a filter based on various risk criteria, that will allow `pak` to
leverage the same internal mechanisms for fetching packages and ensuring, at the
time of download, that packages adhere to the filters that we specify.
Now apply a filter and observe a reduced subset of available packages.
```{r}
options(
available_packages_filters = risk_filter(
RemoteChecks > 0.9,
HasNews == "1"
)
)
nrow(available.packages())
```
Install a package, and confirm that the package was pulled from the bundled
download location, ensuring that the downloaded version of the package is the
same that was used to derive the risk metrics.
```{r}
pak::cache_clean()
pkg <- "colorspace"
if (pkg %in% rownames(installed.packages()))
pak::pkg_remove(pkg)
install_stats <- pak::pkg_install(pkg)
install_stats$sources
```