---
title: "CRAN packages for generalized linear models and with related methods"
author: "[Ioannis Kosmidis](http://www.ikosmidis.com)"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{CRAN "glm" packages}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6,
  fig.height = 6
)
```

### Packages for glm's and associated methods
The current vignette is a quick analysis of all CRAN packages that have "glm" in their name. The crude assumption we make here is that a package with "glm" in its name does something related to generalized linear models.

### Preparing today's CRAN package database

Download today's CRAN database and clean and organize author names, depends, imports, suggests, enhances.
```{r}
library("cranly")
p_db <- tools::CRAN_package_db()
package_db <- clean_CRAN_db(p_db)
```

Let's build the CRAN package directives and collaboration networks
```{r}
package_network <- build_network(package_db)
author_network <- build_network(package_db, perspective = "author")
```

### Packages for generalized linear models

The packages that have "glm" in their name are
```{r}
(glm_packages <- package_with(package_network, name = "glm"))
```

The sub-network for `glm_packages` can be visualized using
```{r}
plot(package_network, package = glm_packages)
```
In order to focus on the sub-network with edges *only* between the packages in `glm_packages`, we do
```{r}
glm_package_only_network <- subset(package_network, package = glm_packages, only = TRUE)
plot(glm_package_only_network, package = glm_packages)
```

The top-20 packages in terms of various statistics of the directives sub-network for generalized linear models according to the number they are imported by other packages
```{r}
glm_package_network <- subset(package_network, package = glm_packages)
glm_package_summaries <- summary(glm_package_network)
plot(glm_package_summaries, according_to = "n_imported_by")
```

The top-20 in the collaboration sub-network for generalized linear models according to the number of collaborators is
```{r}
glm_author_network <- subset(author_network, package = glm_packages)
glm_author_summaries <- summary(glm_author_network)
plot(glm_author_summaries, according_to = "n_collaborators")
```
