Extracting information from cranly package networks: extractors and word clouds

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6,
  fig.height = 6
)

cranly extractor functions

Since version 0.3, cranly includes functions for extracting information from cranly_network objects (see ?extractor-functions). All extractor functions in cranly try to figure out what y is in the statements

y is [the] extractor-function a package/author

Let's download, clean and organize today's CRAN database, and build the package and author directives networks

library("cranly")
library("magrittr")
cran_db <- clean_CRAN_db()
package_network <- cran_db %>% build_network(perspective = "package")
author_network <- cran_db %>% build_network(perspective = "author")

Example queries

Packages by Kurt Hornik

package_network %>% package_by("Kurt Hornik", exact = TRUE)

Packages by people named "Ioannis"

package_network %>% package_by("Ioannis")

Packages with "glm" in their name

author_network %>% package_with("glm")

Authors of the lubridate package

package_network %>% author_of("lubridate", exact = TRUE)

Authors with "Ioan" in their name

package_network %>% author_with("Ioan")

Packages suggested by, imported by and enhanced by the sf package

package_network %>% suggested_by("sf", exact = TRUE)
package_network %>% imported_by("sf", exact = TRUE)
package_network %>% enhanced_by("sf", exact = TRUE)

Packages that are suggesting, importing, enhancing the sf package

package_network %>% suggesting("sf", exact = TRUE)
package_network %>% importing("sf", exact = TRUE)
package_network %>% enhancing("sf", exact = TRUE)

Packages that depend on the sf package

package_network %>% depending_on("sf", exact = TRUE)

Packages that are dependencies of the sf package

package_network %>% dependency_of("sf", exact = TRUE)

Packages maintained by everyone with "Helen" in their name

package_network %>% maintained_by("Helen")

All available info, on packages maintained by everyone with "Helen" in their name

package_network %>% maintained_by("Helen", flat = FALSE) %>% dim()

The maintainer of data.table

package_network %>% maintainer_of("data.table", exact = TRUE)

The email of the maintainer of trackeRapp

trackeRapp_maintainer <- package_network %>% maintainer_of("trackeRapp", exact = TRUE)
package_network %>% email_of(trackeRapp_maintainer, exact = TRUE)

All emails of maintainers using an email address from University of Warwick

package_network %>% email_with("warwick.ac.uk")

The title, the description, the version and the license of the semnar package

package_network %>% title_of("semnar", exact = TRUE)
package_network %>% description_of("semnar", exact = TRUE)
package_network %>% version_of("semnar", exact = TRUE)

Distribution of the release dates of all packages in CRAN

package_network %>% release_date_of(Inf) %>%
    hist(breaks = 50, main = "", xlab = "date", freq = TRUE)

Word clouds

Since version 0.5 cranly provides methods to construct word clouds of either author names, package descriptions or package titles. For example, the word cloud of the descriptions of the packages maintained by me, Achim Zeileis, and Edzer Pebesma are

word_cloud(package_network, maintainer = "Ioannis Kosmidis", exact = TRUE, min.freq = 1)
word_cloud(package_network, maintainer = "Achim Zeileis", exact = TRUE, min.freq = 1)
word_cloud(package_network, maintainer = "Edzer Pebesma", exact = TRUE, min.freq = 1)

or the word cloud of the titles of those packages are

word_cloud(package_network, maintainer = "Ioannis Kosmidis", perspective = "title", exact = TRUE,
           scale = c(2, 0.1), min.freq = 1)
word_cloud(package_network, maintainer = "Achim Zeileis", perspective = "title", exact = TRUE,
           scale = c(2, 0.1), min.freq = 1)
word_cloud(package_network, maintainer = "Edzer Pebesma", perspective = "title", exact = TRUE,
           scale = c(2, 0.1), min.freq = 1)

More complex queries can be achieved by using the extractor functions and computing the term frequencies manually. For example, the word cloud of all packages maintained by people with "warwick.ac.uk" in their email is

warwick_emails <- package_network %>% email_with("warwick.ac.uk", flat = FALSE)
warwick_pkgs  <- warwick_emails$package
descriptions <- package_network %>% description_of(warwick_pkgs, exact = FALSE)
term_frequency <- compute_term_frequency(descriptions)
word_cloud(term_frequency, min.freq = 1)


Try the cranly package in your browser

Any scripts or data that you put into this service are public.

cranly documentation built on Oct. 9, 2019, 1:04 a.m.