Closed mpadge closed 2 years ago
library (pkgstats)
packageVersion ("pkgstats")
#> [1] '0.0.1.6'
u <- "https://cran.r-project.org/src/contrib/dplyr_1.0.7.tar.gz"
path <- file.path (tempdir (),
tail (strsplit (u, "\\/") [[1]], 1))
download.file (u, destfile = path)
s <- pkgstats (path)
pkgstats_summary (s)$external_calls
#> [1] "base:654,DBI:3,dplyr:316,generics:22,glue:7,graphics:1,lobstr:3,methods:11,pillar:4,rlang:3,RSQLite:1,stats:5,tidyselect:9,utils:10,vctrs:5"
# Counts of numbers of external calls to different pkgs
# Can be processed to extract further info:
x <- strsplit (pkgstats_summary (s)$external_calls, ",") [[1]]
x <- do.call (rbind, strsplit (x, ":"))
x <- data.frame (pkg = x [, 1],
ncalls = as.integer (x [, 2]))
x$ncalls_rel <- round (x$ncalls / sum (x$ncalls), 3)
x <- x [order (x$ncalls, decreasing = TRUE), ]
rownames (x) <- NULL
print (x)
#> pkg ncalls ncalls_rel
#> 1 base 654 0.620
#> 2 dplyr 316 0.300
#> 3 generics 22 0.021
#> 4 methods 11 0.010
#> 5 utils 10 0.009
#> 6 tidyselect 9 0.009
#> 7 glue 7 0.007
#> 8 stats 5 0.005
#> 9 vctrs 5 0.005
#> 10 pillar 4 0.004
#> 11 DBI 3 0.003
#> 12 lobstr 3 0.003
#> 13 rlang 3 0.003
#> 14 graphics 1 0.001
#> 15 RSQLite 1 0.001
Created on 2021-09-22 by the reprex package (v2.0.0.9000)
Re-opened to also add number of unique functions from each package to summary output
library (pkgstats)
packageVersion ("pkgstats")
#> [1] '0.0.1.10'
u <- "https://cran.r-project.org/src/contrib/dplyr_1.0.7.tar.gz"
path <- file.path (tempdir (), tail (strsplit (u, "\\/") [[1]], 1))
download.file (u, destfile = path)
s <- pkgstats (path)
x <- strsplit (pkgstats_summary (s)$external_calls, ",") [[1]]
x <- do.call (rbind, strsplit (x, ":"))
x <- data.frame (pkg = x [, 1],
n_total = as.integer (x [, 2]),
n_unique = as.integer (x [, 3]))
x$n_total_rel <- round (x$n_total / sum (x$n_total), 3)
x$n_unique_rel <- round (x$n_unique / sum (x$n_unique), 3)
x <- x [order (x$n_total, decreasing = TRUE), ]
rownames (x) <- NULL
print (x)
#> pkg n_total n_unique n_total_rel n_unique_rel
#> 1 base 654 107 0.620 0.446
#> 2 dplyr 316 108 0.300 0.450
#> 3 generics 22 1 0.021 0.004
#> 4 methods 11 3 0.010 0.013
#> 5 utils 10 3 0.009 0.013
#> 6 tidyselect 9 3 0.009 0.013
#> 7 glue 7 1 0.007 0.004
#> 8 stats 5 5 0.005 0.021
#> 9 vctrs 5 1 0.005 0.004
#> 10 pillar 4 1 0.004 0.004
#> 11 DBI 3 1 0.003 0.004
#> 12 lobstr 3 2 0.003 0.008
#> 13 rlang 3 2 0.003 0.008
#> 14 graphics 1 1 0.001 0.004
#> 15 RSQLite 1 1 0.001 0.004
Created on 2021-09-23 by the reprex package (v2.0.1.9000)
Re-opened because the extraction of calls is too crude, and needs to be improved. Next commit will implement that.
They're currently not namespaced, preventing ability to map calls between packages