Skip to content

Commit

Permalink
Updating site
Browse files Browse the repository at this point in the history
  • Loading branch information
edpeyton committed Nov 25, 2024
1 parent 08a1d70 commit 819d46b
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 120 deletions.
30 changes: 12 additions & 18 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,19 @@ knitr::opts_chunk$set(

Have you ever wanted to visualize dependencies between functions for a group of R packages you have developed?

Then try using `{pkgdepR}`!

`{pkgdepR}` takes any number of (correctly compiled) R packages and finds the links between all of the function in those namespaces.
`pkgdepR` takes any number of (correctly compiled) R packages and finds the links between all of the function in those namespaces.

## About

### Why create `{pkgdepR}`?
### Motivation

`{pkgdepR}` was created to solve a particular problem I had faced when developing interrelated R packages within organizations. Oftentimes, I would want to see (visually) how all the functions in one package interacted with all the functions in another package.
`pkgdepR` was created to solve a particular problem when developing interrelated R packages and wanting to see how all the functions in each package interacted.

This was particularly useful in managing the function dependencies across a large code base of R packages.

### How does `{pkgdepR}` work?
### How does it work?

`{pkgdepR}` simply takes as an argument a vector of package names (that should already be on the search path) and explores how each of the functions in each of the namespaces interact. It does this in two stages:
`pkgdepR` simply takes as an argument a vector of package names (that should already be on the search path) and explores how each of the functions in each of the namespaces interact. It does this in two stages:

* Getting all intra-package function dependencies for each package; *and*
* Getting all inter-package function dependencies for each combination of packages.
Expand All @@ -47,14 +45,13 @@ Each defined name in a particular package's namespace that is also a function is

If a function is ambiguously called (without a package tag or not being explicitly imported from another namespace) then it is deliberately ignored in the linkage. This is because the linkage would be environment-dependent and would change depending on the contents of the search path in that particular session.

### S3 methods for `{pkgdepR}` objects
### S3 methods

The main wrapper function for `{pkgdepR}` is `pkgdepR::deps(...)` which returns an object of class `pkgdepR`. An S3 method has been created for objects of class `pkgdepR` so they can be easily plotted. See `?pkgdepR::plot.pkgdepR` for further details.
The main wrapper function for `pkgdepR` is `pkgdepR::deps(...)` which returns an object of class `pkgdepR`. An S3 method has been created for objects of class `pkgdepR` so they can be easily plotted. See `?pkgdepR::plot.pkgdepR` for further details.

`{pkgdepR}` makes use of the fantastic [visNetwork](https://github.com/datastorm-open/visNetwork) package for creating an interactive network visualization of the functions present in R packages.
`pkgdepR` makes use of the fantastic [visNetwork](https://github.com/datastorm-open/visNetwork) package for creating an interactive network visualization of the functions present in R packages.

```{r loadpkg, include=FALSE}
library(magrittr)
library(pkgdepR)
Expand All @@ -68,7 +65,6 @@ methods(class = "pkgdepR")
## Caveats
The links between functions are determined **statically**, meaning the dependencies are identified without executing any code. As such, any functions that are defined dynamically at run-time will not be picked up. In the example below, `foo()` will be picked up as it is declared in the package's namespace. However, `bar()` will not be picked up as it is only defined at run-time when `foo()` is called.
```r

# @title foo function
# @export
foo = function() { # - this will be picked up!
Expand All @@ -86,7 +82,6 @@ foo = function() { # - this will be picked up!
Similarly, there can be cases where linkages are created that may not occur at run-time. Let's add to the previous example, by adding a function `bar()` declared in the package namespace we are interested in.

```r

# @title bar function
# @export
bar = function() { # - this will be picked up!
Expand All @@ -101,7 +96,7 @@ These cases will rarely arise in normal package development, but it is important

## Installation

You can install the released version of `{pkgdepR}` from [CRAN](https://CRAN.R-project.org) with:
You can install the released version of `pkgdepR` from [CRAN](https://CRAN.R-project.org) with:

```r
install.packages("pkgdepR")
Expand All @@ -115,12 +110,11 @@ devtools::install_github("edpeyton/pkgdepR")


# How to use
Here we'll show an example of how to use `{pkgdepR}`.
Here we'll show an example of how to use `pkgdepR`.

First, let's load the required packages.

```r

library(magrittr)
library(pkgdepR)

Expand All @@ -137,7 +131,7 @@ v = pkgdepR::deps(pkg = "pkgdepR")

We can see a summary of the object
```{r single2, eval = T}
v # alternatively, summary(v) or print(v)
v
```

To see the network visualization, simply call plot.
Expand All @@ -153,7 +147,7 @@ v = pkgdepR::deps(pkg = c("pkgdepR", "magrittr"))
```

```{r multiple2, eval = T}
v # alternatively, summary(v) or print(v)
v
```

```{r multiple1, eval = F}
Expand Down
34 changes: 14 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,23 @@ stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://
Have you ever wanted to visualize dependencies between functions for a
group of R packages you have developed?

Then try using `{pkgdepR}`!

`{pkgdepR}` takes any number of (correctly compiled) R packages and
finds the links between all of the function in those namespaces.
`pkgdepR` takes any number of (correctly compiled) R packages and finds
the links between all of the function in those namespaces.

## About

### Why create `{pkgdepR}`?
### Motivation

`{pkgdepR}` was created to solve a particular problem I had faced when
developing interrelated R packages within organizations. Oftentimes, I
would want to see (visually) how all the functions in one package
interacted with all the functions in another package.
`pkgdepR` was created to solve a particular problem when developing
interrelated R packages and wanting to see how all the functions in each
package interacted.

This was particularly useful in managing the function dependencies
across a large code base of R packages.

### How does `{pkgdepR}` work?
### How does it work?

`{pkgdepR}` simply takes as an argument a vector of package names (that
`pkgdepR` simply takes as an argument a vector of package names (that
should already be on the search path) and explores how each of the
functions in each of the namespaces interact. It does this in two
stages:
Expand All @@ -61,14 +58,14 @@ ignored in the linkage. This is because the linkage would be
environment-dependent and would change depending on the contents of the
search path in that particular session.

### S3 methods for `{pkgdepR}` objects
### S3 methods

The main wrapper function for `{pkgdepR}` is `pkgdepR::deps(...)` which
The main wrapper function for `pkgdepR` is `pkgdepR::deps(...)` which
returns an object of class `pkgdepR`. An S3 method has been created for
objects of class `pkgdepR` so they can be easily plotted. See
`?pkgdepR::plot.pkgdepR` for further details.

`{pkgdepR}` makes use of the fantastic
`pkgdepR` makes use of the fantastic
[visNetwork](https://github.com/datastorm-open/visNetwork) package for
creating an interactive network visualization of the functions present
in R packages.
Expand All @@ -91,7 +88,6 @@ the package’s namespace. However, `bar()` will not be picked up as it is
only defined at run-time when `foo()` is called.

``` r

# @title foo function
# @export
foo = function() { # - this will be picked up!
Expand All @@ -110,7 +106,6 @@ occur at run-time. Let’s add to the previous example, by adding a
function `bar()` declared in the package namespace we are interested in.

``` r

# @title bar function
# @export
bar = function() { # - this will be picked up!
Expand All @@ -130,7 +125,7 @@ important to be aware of the behaviour nonetheless.

## Installation

You can install the released version of `{pkgdepR}` from
You can install the released version of `pkgdepR` from
[CRAN](https://CRAN.R-project.org) with:

``` r
Expand All @@ -146,12 +141,11 @@ devtools::install_github("edpeyton/pkgdepR")

# How to use

Here we’ll show an example of how to use `{pkgdepR}`.
Here we’ll show an example of how to use `pkgdepR`.

First, let’s load the required packages.

``` r

library(magrittr)
library(pkgdepR)
```
Expand All @@ -169,7 +163,7 @@ v = pkgdepR::deps(pkg = "pkgdepR")
We can see a summary of the object

``` r
v # alternatively, summary(v) or print(v)
v
#>
#> pkgdepR object
#> ------------------------------
Expand Down
Loading

0 comments on commit 819d46b

Please sign in to comment.