@@ -16,7 +16,7 @@ output:
1616[ ![ CRAN Downloads] ( https://cranlogs.r-pkg.org/badges/grand-total/pkgstats?color=orange )] ( https://cran.r-project.org/package=pkgstats )
1717<!-- badges: end -->
1818
19- ``` {r, include = FALSE, echo = FALSE}
19+ ``` {r, include = FALSE, echo = FALSE, eval = FALSE }
2020if (identical (Sys.getenv ("IN_PKGDOWN"), "true")) {
2121 pkgstats::ctags_install ()
2222}
@@ -69,22 +69,69 @@ using an internally bundled `.tar.gz` "tarball" of this package. The
6969` system.time ` call demonstrates that the static code analyses of ` pkgstats ` are
7070generally very fast.
7171
72- ``` {r demo}
72+ ``` {r demo, eval = FALSE }
7373library (pkgstats)
7474tarball <- system.file ("extdata", "pkgstats_9.9.tar.gz", package = "pkgstats")
7575system.time (
7676 p <- pkgstats (tarball)
7777)
78+ ```
79+ ``` {r demo-tarball, echo = FALSE}
80+ library (pkgstats)
81+ tarball <- system.file ("extdata", "pkgstats_9.9.tar.gz", package = "pkgstats")
82+ path <- extract_tarball (tarball)
83+ ```
84+
85+
86+
87+ ``` {r demo-output-systime, echo = FALSE, eval = TRUE}
88+ c (user = 1.701, system = 0.124, elapsed = 1.802)
89+ ```
90+
91+ ``` {r demo-names, eval = FALSE}
7892names (p)
7993```
8094
95+ ``` {r demo-output, echo = FALSE, eval = TRUE}
96+ c (
97+ "loc", "vignettes", "data_stats", "desc", "translations",
98+ "objects", "network", "external_calls"
99+ )
100+ ```
101+
102+
81103The result is a list of various data extracted from the code. All except for
82104` objects ` and ` network ` represent summary data:
83105
84- ``` {r}
106+ ``` {r pout, eval = FALSE, echo = TRUE }
85107p [!names (p) %in% c ("objects", "network", "external_calls")]
86108```
87109
110+ ``` {r pout-fakey, eval = TRUE, echo = FALSE}
111+ p <- list (
112+ loc = tibble::tibble (
113+ langage = c ("C++", "R", "R", "R"),
114+ dir = c ("src", "R", "tests", "tests/testthat"),
115+ nfiles = as.integer (c (3, 19, 2, 5)),
116+ nlines = as.integer (c (365, 3741, 146, 202)),
117+ ncode = as.integer (c (277, 2698, 121, 145)),
118+ ndoc = as.integer (c (21, 536, 1, 9)),
119+ nempty = as.integer (c (67, 507, 24, 48)),
120+ nspaces = as.integer (c (933, 27575, 395, 375)),
121+ nchars = as.integer (c (7002, 94022, 2423, 3738)),
122+ nexpr = rep (1, 4),
123+ ntabs = rep (0L, 4),
124+ indentation = rep (4L, 4)
125+ ),
126+ vignettes = c (vignettes = 0L, demos = 0L),
127+ data_stats = c (n = 0L, total_size = 0L, median_size = 0L),
128+ desc = desc_stats (path),
129+ translations = NA
130+ )
131+ p
132+ ```
133+
134+
88135The various components of these results are described in further detail in the
89136[ main package
90137vignette] ( https://docs.ropensci.org/pkgstats/articles/pkgstats.html ) .
@@ -96,21 +143,27 @@ A summary of the `pkgstats` data can be obtained by submitting the object
96143returned from ` pkgstats() ` to the [ ` pkgstats_summary() `
97144function] ( https://docs.ropensci.org/pkgstats/reference/pkgstats_summary.html ) :
98145
99- ``` {r summary, echo = TRUE}
146+ ``` {r summary, echo = TRUE, eval = FALSE }
100147s <- pkgstats_summary (p)
101148```
102149
150+ ``` {r summary-ncols, echo = FALSE, eval = TRUE}
151+ ncol_s <- 95L
152+ ```
153+
154+
155+
103156This function reduces the result of the [ ` pkgstats() `
104157function] ( https://docs.ropensci.org/pkgstats/reference/pkgstats_summary.html )
105- to a single line with ` r ncol (s) ` entries, represented as a ` data.frame ` with
158+ to a single line with ` r ncol_s ` entries, represented as a ` data.frame ` with
106159one row and that number of columns. This format is intended to enable summary
107160statistics from multiple packages to be aggregated by simply binding rows
108- together. While ` r ncol (s) ` statistics might seem like a lot, the
161+ together. While ` r ncol_s ` statistics might seem like a lot, the
109162[ ` pkgstats_summary() `
110163function] ( https://docs.ropensci.org/pkgstats/reference/pkgstats_summary.html )
111164aims to return as many usable raw statistics as possible in order to flexibly
112165allow higher-level statistics to be derived through combination and
113- aggregation. These ` r ncol (s) ` statistics can be roughly grouped into the
166+ aggregation. These ` r ncol_s ` statistics can be roughly grouped into the
114167following categories (not shown in the order in which they actually appear),
115168with variable names in parentheses after each description. Some statistics are
116169summarised as comma-delimited character strings, such as translations into
@@ -145,12 +198,27 @@ of all package dependencies, as demonstrated immediately below.
145198Numbers of entries in each the of the last two kinds of items can be obtained
146199from by a simple ` strsplit ` call, like this:
147200
148- ``` {r strsplit}
201+ ``` {r strsplit, echo = TRUE, eval = FALSE }
149202deps <- strsplit (s$suggests, ", ") [[1]]
150203length (deps)
151204print (deps)
152205```
153206
207+ ``` {r strsplit-out1, echo = FALSE, eval = TRUE}
208+ 9L
209+ ```
210+
211+ ``` {r strsplit-deps, echo = TRUE, eval = FALSE}
212+ print (deps)
213+ ```
214+
215+ ``` {r strsplit-out2, echo = FALSE, eval = TRUE}
216+ c (
217+ "hms", "knitr", "pbapply", "pkgbuild", "Rcpp",
218+ "rmarkdown", "roxygen2", "testthat", "visNetwork"
219+ )
220+ ```
221+
154222** Numbers of files and associated data**
155223
156224- Number of vignettes (` num_vignettes ` )
@@ -238,14 +306,23 @@ of function calls, and total numbers of unique function calls. Data for each
238306package are separated by a comma, while data within each package are separated
239307by a colon.
240308
241- ``` {r summary-external-calls}
309+ ``` {r summary-external-calls, echo = TRUE, eval = FALSE }
242310s$external_calls
243311```
312+ ``` {r external-calls-out, echo = FALSE, eval = TRUE}
313+ paste0 (
314+ "base:447:78,brio:7:1,dplyr:7:4,fs:4:2,graphics:10:2,",
315+ "hms:1:1,igraph:3:3,pbapply:1:1,pkgstats:99:60,readr:8:5,",
316+ "stats:16:2,sys:13:1,tools:2:2,utils:10:7,visNetwork:3:2,withr:5:1"
317+ )
318+ ```
319+
320+
244321
245322This structure allows numbers of calls to all packages to be readily extracted
246323with code like the following:
247324
248- ``` {r summary-exteranl -calls-transform}
325+ ``` {r summary-external -calls-transform, echo = TRUE, eval = FALSE }
249326calls <- do.call (
250327 rbind,
251328 strsplit (strsplit (s$external_call, ",") [[1]], ":")
@@ -258,6 +335,24 @@ calls <- data.frame (
258335print (calls)
259336```
260337
338+ ``` {r summary-external-calls-out, echo = FALSE, eval = TRUE}
339+ data.frame (
340+ package = c (
341+ "base", "brio", "dplyr", "fs", "graphics", "hms", "igraph", "pbapply",
342+ "pkgstats", "readr", "stats", "sys", "tools", "utils", "visNetwork",
343+ "withr"
344+ ),
345+ n_total = as.integer (c (
346+ 447, 7, 7, 4, 10, 1, 3, 1, 99, 8, 16, 13, 2, 10, 3, 5
347+ )),
348+ n_unique = as.integer (c (
349+ 78, 1, 4, 2, 2, 1, 3, 1, 60, 5, 2, 1, 2, 7, 2, 1
350+ ))
351+ )
352+ ```
353+
354+
355+
261356The two numeric columns respectively show the total number of calls made to
262357each package, and the total number of unique functions used within those
263358packages. These results provide detailed information on numbers of calls made
0 commit comments