---
title: "Finding Applied Examples of Ready4 Modules and Sub-modules"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Finding Applied Examples of Ready4 Modules and Sub-modules}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE)
```

```{r message=FALSE, warning=FALSE}
library(ready4)
```

## Motivation
When considering whether to use a model module, it is useful to first see tutorials about appropriate use of that module. 

## Implementation
A table itemising individual model modules and sub-modules authored with `ready4` can be generated using `make_modules_tb`. This function scrapes relevant data from the websites of module libraries that have been developed within a specified project's GitHub organisation.

## Use
In this example, we are going to examine modules from the [readyforwhatsnext model](https://readyforwhatsnext.org/). The value supplied to the `gh_repo_1L_chr` argument specifies the repository in which a dataset of readyforwhatsnext module libraries is stored. Note, the following command may take a couple of minutes to execute.

```{r}
modules_tb <- make_modules_tb(gh_repo_1L_chr = "ready4-dev/ready4")
```

A slightly quicker method to achieve a similar result is to use the `get_modules_tb` function. This function retrieves an archived version (and therefore potentially less up to date) of the modules summary table.

```{r eval=FALSE}
# Not run
# modules_tb <- get_modules_tb(gh_repo_1L_chr = "ready4-dev/ready4")
```

The `modules_tb` object itemises both model [modules (which always use R's "S4" class type) and sub-modules ("S3" class type)](https://www.ready4-dev.com/docs/tutorials/develop-models/modularity/). 

To display a HTML summary of just model modules, you can use the `print_modules` function. 

```{r eval=FALSE}
print_modules(modules_tb, what_1L_chr = "S4")
```

```{r echo=FALSE}
print_modules(modules_tb, what_1L_chr = "S4")
```

You can use the same function to display only model sub-modules.

```{r eval=FALSE}
print_modules(modules_tb, what_1L_chr = "S3")
```

```{r echo=FALSE}
print_modules(modules_tb, what_1L_chr = "S3")
```

## Related content
Details of how to search for themed collections of modules is described in [another article](https://www.ready4-dev.com/docs/tutorials/use-models/finding-modules/collections/). 
