-
Notifications
You must be signed in to change notification settings - Fork 0
/
CRAN_packages.qmd
55 lines (37 loc) · 1.15 KB
/
CRAN_packages.qmd
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
# Dépendances des packages R CRAN
## Chargement des librairies
```{r}
#| label: load_libraries
#| message: false
library(cranly)
```
## Récupérer les données du CRAN
L'outil de référence pour collecter les informations à jour des paquets est la commande `CRAN_package_db()`du package `tools`
```{r}
#| label: packages_list
package_db_file <- "data/package_db.RDS"
if (file.exists(package_db_file)) {
package_db <- readRDS(package_db_file)
} else {
package_db <- tools::CRAN_package_db()
saveRDS(package_db, file = package_db_file)
}
head(package_db[,1:4])
nrow(package_db)
```
## Construction d'un arbre des dépendances avec `cranly`^[[R package dependence trees](https://cran.r-project.org/web/packages/cranly/vignettes/dependence_trees.html)]
```{r}
#| label: cranly_tree
library(cranly)
if (file.exists(package_db_file)) {
package_db <- readRDS(package_db_file)
cran_db <- clean_CRAN_db(package_db)
} else {
cran_db <- clean_CRAN_db()
}
package_network <- build_network(cran_db)
package <- "visNetwork"
compute_dependence_tree(package_network, package)
tibble_tree <- build_dependence_tree(package_network, package)
plot(tibble_tree)
```