-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
582 lines (449 loc) · 26.7 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(manynet)
list_functions <- function(string){
paste0("`", paste(paste0(ls("package:manynet")[grepl(string, ls("package:manynet"))], "()"), collapse = "`, `"), "`")
}
list_data <- function(string){
paste0("`", paste(paste0(ls("package:manynet")[grepl(string, ls("package:manynet"))]), collapse = "`, `"), "`")
}
```
# manynet
<img src="man/figures/logo.png" align="right" alt="manynet logo" width="150"/>
<!-- badges: start -->
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#maturing)
![CRAN/METACRAN](https://img.shields.io/cran/v/manynet)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/stocnet/manynet)
![GitHub Release Date](https://img.shields.io/github/release-date/stocnet/manynet)
[![Codecov test coverage](https://codecov.io/gh/stocnet/manynet/branch/main/graph/badge.svg)](https://app.codecov.io/gh/stocnet/manynet?branch=main)
<!-- [![CodeFactor](https://www.codefactor.io/repository/github/stocnet/manynet/badge)](https://www.codefactor.io/repository/github/stocnet/manynet) -->
<!-- [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4559/badge)](https://bestpractices.coreinfrastructure.org/projects/4559) -->
<!-- [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7076396.svg)](https://doi.org/10.5281/zenodo.7076396) -->
<!-- see https://zenodo.org/record/7076396 -->
<!-- ![GitHub All Releases](https://img.shields.io/github/downloads/stocnet/migraph/total) -->
<!-- badges: end -->
## About the package
While many awesome packages for network analysis exist for R,
all with their own offerings and advantages,
they also all have their own vocabulary, syntax,
and expected formats for data inputs and analytic outputs.
Many of these packages only work on _some_ types of networks
(usually one-mode, simple, directed or undirected networks) for _some_ types of analysis;
if you want to analyse a different type of network or try a different analysis,
a different package is needed.
And they can rely on a very different visual language (and sometimes plotting engine),
which can mess up your pretty presentation or paper.
This can make learning and using network analysis tools in R challenging.
By contrast, `{manynet}` offers _many_ analytic tools that work on _many_ (if not most) types and kinds of networks.
It helps researchers make, modify, map, mark, measure, and identify nodes' motifs and memberships in networks.
For further testing and modelling capabilities,
see [`{migraph}`](https://stocnet.github.io/migraph/) and the other [stocnet](https://github.com/stocnet) packages.
- [Making](#making)
- [Importing network data](#importing-network-data)
- [Identifying network data](#identifying-network-data)
- [Inventing network data](#inventing-network-data)
- [Translating network data](#translating-network-data)
- [Modifying](#modifying)
- [Reformatting](#reformatting)
- [Transforming](#transforming)
- [Splitting and Joining](#splitting-and-joining)
- [Extracting](#extracting)
- [Mapping](#mapping)
- [Graphing](#graphing)
- [More options](#more-options)
- [More layouts](#more-layouts)
- [More themes and scales](#more-themes-and-scales)
- [graphs](#graphs)
- [grapht](#grapht)
- [Marking](#marking)
- [Motifs](#motifs)
- [Memberships](#memberships)
- [Measuring](#measuring)
- [Tutorials](#tutorials)
- [Installation](#installation)
- [Stable](#stable)
- [Development](#development)
- [Relationship to other packages](#relationship-to-other-packages)
- [Funding details](#funding-details)
## Making
Networks can come from many sources and be found in many different formats:
some can be found in this or other packages,
some can be created or generated using functions in this package,
and others can be downloaded from the internet and imported from your file system.
`{manynet}` provides tools to make networks from all these sources in any number of common formats.
#### Importing network data
`{manynet}` offers a number of options
for importing network data found in other repositories.
Besides importing and exporting to Excel edgelists, nodelists, and (bi)adjacency matrices,
there are specific routines included for
[UCINET](http://www.analytictech.com/archive/ucinet.htm),
[Pajek](http://mrvar.fdv.uni-lj.si/pajek/),
[GraphML](http://graphml.graphdrawing.org),
and [DynetML](http://casos.cs.cmu.edu/projects/dynetml/) files, e.g.:
<img src="https://www.jameshollway.com/post/manynet/README-import-graph-1.png" alt="Graph of manynet input/output formats"/>
```{r import-graph, echo = FALSE, dpi = 300, fig.height=2.5, eval=FALSE}
library(patchwork)
library(ggplot2)
imports <- igraph::graph_from_literal(ucinet:pajek+--+tidygraph,
matrix:dynetml--+tidygraph,
edgelist:nodelist+--+tibble)
imports <- imports %>% mutate(type = ifelse(node_names(imports)%in% c("tidygraph","tibble"), TRUE, FALSE))
graphr(imports, node_size = 4)
```
If you cannot remember the file name/path, then just run `read_*()` with the parentheses empty,
and a file selection popup will open so that you can browse through your file system to find the file.
Usually both `read_*()` and `write_*()` are offered to make sure that `{manynet}` is compatible with your
larger project and analytic workflow.
- `r list_functions("^read_")`
- `r list_functions("^write_")`
#### Identifying network data
There may be no need to import network data though, if that network data already exists in a package in R.
To facilitate testing and to contribute to an ecosystem of easily accessible network data,
particularly for pedagogical purposes,
we include a number of classical and instructional network datasets,
all thoroughly documented and ready for analysis.
Here are just a few examples, all available in `{manynet}`:
<img src="https://www.jameshollway.com/post/manynet/README-ison_egs-1.png" alt="Graphs illustrating several of the classic networks included in the package"/>
```{r ison_egs, echo = FALSE, dpi = 250, message=FALSE, fig.height=3, eval=FALSE}
graphr(to_unnamed(ison_karateka)) + ggtitle("Karateka", subtitle = "Zachary 1977") +
graphr(ison_algebra, labels = FALSE) + ggtitle("Algebra", subtitle = "McFarland 2001") +
graphr(to_unnamed(ison_southern_women)) + ggtitle("Southern Women", subtitle = "Davis et al 1941")
#/
# (graphr(ison_lawfirm) + ggtitle("Law Firm", subtitle = "Lazega 2001") +
```
Here are some others: `r list_data("^ison_")`
#### Inventing network data
`{manynet}` includes functions for making networks algorithmically.
The `create_*` group of functions create networks with a particular structure,
and will always create the same format from the same inputs,
e.g.:
<img src="https://www.jameshollway.com/post/manynet/README-create_egs-1.png" alt="Graphs illustrating the creation of lattices and tree networks"/>
```{r create_egs, echo = FALSE, dpi = 300, message=FALSE, fig.height=3, eval=FALSE}
(graphr(create_lattice(15)) + ggtitle("Lattice", subtitle = "create_lattice(15)") +
graphr(create_tree(15)) + ggtitle("Tree", subtitle = "create_tree(15)"))
```
See also `r list_functions("^create_")`.
The `generate_*` group of functions generate networks from
generative mechanisms that may include some random aspect,
and so will return a different output each time they are run,
e.g.:
<img src="https://www.jameshollway.com/post/manynet/README-generate_egs-1.png" alt="Graphs of small-world and scale-free networks of 15 nodes"/>
```{r generate_egs, echo = FALSE, dpi = 300, message=FALSE, fig.height=3, eval=FALSE}
(graphr(generate_smallworld(15)) + ggtitle("Small-World", subtitle = "generate_smallworld(15)") +
graphr(generate_scalefree(15)) + ggtitle("Scale-Free", subtitle = "generate_scalefree(15)"))
```
See also `r list_functions("^generate_")`.
Note that all these functions can create directed or undirected,
one-mode or two-mode networks.
Creating two-mode networks is as easy as passing the first argument (`n`)
a vector of two integers instead of one.
For example, while `n = 15` will create a one-mode network of 10 nodes,
whereas `n = c(10,5)` will create a two-mode network of 10 nodes in the first mode,
and 5 nodes in the second mode.
Some of these functions wrap existing algorithms in other packages,
while others are unique offerings or add additional formats,
e.g. two-mode networks.
<img src="https://www.jameshollway.com/post/manynet/README-generate_tm-1.png" alt="Graphs of generated one- and two-mode small-world networks"/>
```{r generate_tm, echo = FALSE, dpi = 300, message=FALSE, fig.height=3, warning=FALSE, eval=FALSE}
graphr(generate_smallworld(15, directed = TRUE), layout = "stress") + ggtitle("Small-World", subtitle = "generate_smallworld(15, directed = TRUE)") + graphr(generate_smallworld(c(10,5)), layout = "stress") + ggtitle("Small-World", subtitle = "generate_smallworld(c(10,5))")
```
#### Inventing data on networks
Lastly, `{manynet}` also includes functions for simulating diffusion
or learning processes over a given network:
- `r list_functions("^play_")`
The diffusion models include not only SI and threshold models,
but also SIS, SIR, SIRS, SEIR, and SEIRS.
## Modifying
Before or during analysis, you may need to modify the network you are analysing in various ways.
Different packages have different syntaxes and vocabulary for such actions;
`{manynet}`'s `to_*()` functions can be used on any class object
to reformat, transform, or split networks into networks with other properties.
#### Translating network data
Once you have imported network data,
identified network data in this or other packages in R,
or invented your own,
you may need to translate this data into another class for analysis.
`{manynet}`'s `as_*()` functions can be used to coerce objects
from one of many common classes into any other.
Below is a directed graph showing the currently available options:
<img src="https://www.jameshollway.com/post/manynet/README-coercion-graph-1.png" alt="Graph of coercible relationships between classes"/>
```{r coercion-graph, echo = FALSE, dpi = 300, eval=FALSE, fig.height=8, fig.width=8}
graphr(igraph::graph_from_literal(edgelist:matrix:igraph:network:tidygraph+--+edgelist:matrix:igraph:network:tidygraph,
edgelist:matrix:igraph:network:tidygraph--+graphAM,
tidygraph:igraph--+siena,
diff_model--+tidygraph:igraph:matrix:diffnet,
diffnet--+igraph:network:diff_model:tidygraph,
siena:goldfish--+edgelist:matrix:igraph:network:tidygraph:graphAM),
"circle", node_size = 3)
ggsave("~/Library/CloudStorage/Dropbox/Sites/jameshollway.com/content/post/manynet/README-coercion-graph-1.png")
```
These functions are designed to be as intuitive and lossless as possible,
outperforming many other class-coercion packages.
We use these functions internally in every `{manynet}` and `{migraph}` function to
(1) allow them to be run on any compatible network format
and (2) use the most efficient algorithm available.
This makes `{manynet}` and `{migraph}` compatible with your existing workflow,
whether you use base R matrices or edgelists as data frames,
[`{igraph}`](https://igraph.org/r/),
[`{network}`](https://statnet.org), or
[`{tidygraph}`](https://tidygraph.data-imaginist.com/index.html),
and extensible by developments in those other packages too.
### Reformatting
Reformatting means changing the format of the network,
e.g. from directed to undirected via `to_undirected()`.
<img src="https://www.jameshollway.com/post/manynet/README-directed_egs-1.png" alt="Graphs illustrating modification of a network's directedness"/>
```{r directed_egs, echo = FALSE, dpi = 300, fig.height=3, warning=FALSE, message=FALSE, eval=FALSE}
graphr(to_directed(ison_brandes)) + ggtitle("Directed", subtitle = "to_directed(ison_brandes)") +
graphr(to_undirected(ison_brandes)) + ggtitle("Undirected", subtitle = "to_undirected(ison_brandes)")
```
### Transforming
Transforming means changing the dimensions of the network,
e.g. from a two-mode network to a one-mode projection via `to_mode1()`.
<img src="https://www.jameshollway.com/post/manynet/README-projection_egs-1.png" alt="Graphs illustrating decomposition of a two-mode network into its projections"/>
```{r projection_egs, echo = FALSE, dpi = 300, fig.height=3, warning=FALSE, message=FALSE, eval=FALSE}
graphr(ison_southern_women, layout = "stress") + ggtitle("Original", subtitle = "ison_southern_women") +
graphr(to_mode1(ison_southern_women)) + ggtitle("Row Projection", subtitle = "to_mode1(ison_southern_women)") +
graphr(to_mode2(ison_southern_women)) + ggtitle("Column Projection", subtitle = "to_mode2(ison_southern_women)") &
ggplot2::theme(plot.subtitle = element_text(size = 10))
```
### Splitting and Joining
Splitting means separating a network,
e.g. from a whole network to the various ego networks via `to_egos()`.
<img src="https://www.jameshollway.com/post/manynet/README-splitting_egs-1.png" alt="Graphs illustrating decomposition of a network into egonets"/>
```{r splitting_egs, echo = FALSE, dpi = 250, fig.height=4, warning=FALSE, message=FALSE, eval=FALSE}
graphr(ison_adolescents) + ggtitle("Original", subtitle = "ison_adolescents") +
graphs(lapply(to_egos(ison_adolescents), to_unnamed)) + ggtitle("Ego Splitting", subtitle = "to_egos(ison_adolescents)")
```
Those functions that split a network into a list of networks are
distinguishable as those `to_*()` functions that are named in the plural.
Split data can be rejoined using the `from_*()` family of functions.
See also `r list_functions("^to_")` and `r list_functions("^from_")`.
## Mapping
`{manynet}` includes three one-line graphing functions with sensible defaults based on
the network's properties.
### Graphing
First, `graphr()` is used to graph networks in any of the `{manynet}` formats.
It includes sensible defaults so that researchers can view their network's structure
or distribution quickly with a minimum of fuss.
Compare the output from `{manynet}` with a similar default from `{igraph}`:
<img src="https://www.jameshollway.com/post/manynet/README-layout-comparison-1.png" alt="Example illustrating differences in default igraph and manynet graphs"/>
```{r layout-comparison, echo = FALSE, message=FALSE, dpi = 250, fig.height=4, eval = FALSE}
library(manynet)
library(igraph)
library(gridBase)
library(grid)
par(mfrow=c(1, 2), mai = c(0,0,0.5,0))
plot(as_igraph(ison_southern_women), layout = layout_as_bipartite, main = "{igraph} bipartite")
## the last one is the current plot
plot.new() ## suggested by @Josh
vps <- baseViewports()
pushViewport(vps$figure) ## I am in the space of the autocorrelation plot
vp1 <-plotViewport(c(1.8,1,0,1)) ## create new vp with margins, you play with this values
p <- graphr(ison_southern_women) + ggtitle("{manynet} twomode")
print(p,vp = vp1)
```
Here the `{manynet}` function recognises that the network is a two-mode network
and uses a bipartite layout by default,
and recognises that the network contains names for the nodes and
prints them vertically so that they are legible in this layout.
Other 'clever' features include automatic node sizing and more.
By contrast, `{igraph}` requires the bipartite layout to be specified, has cumbersome node size defaults for all but the smallest graphs, and labels also very often need resizing and adjustment to avoid overlap.
All of `{manynet}`'s adjustments can be overridden, however...
#### More options
Changing the size and colors of nodes and ties is as easy as
specifying the function's relevant argument with a replacement,
or indicating from which attribute it should inherit this information.
<img src="https://www.jameshollway.com/post/manynet/README-more-options-1.png" alt="Graph illustrating automatic and manual use of node color and size"/>
```{r more-options, echo = FALSE, message=FALSE, dpi = 300, fig.height=3, eval=FALSE}
graphr(ison_lawfirm, node_color = "darkblue", node_size = 6) +
ggtitle("Manual options",
subtitle = "graphr(ison_lawfirm, node_color = 'darkblue', node_size = 6)") +
graphr(mutate(ison_lawfirm, Seniority = Seniority/3), node_color = "Office", node_size = "Seniority") +
ggtitle("Automatic options",
subtitle = "graphr(ison_lawfirm, node_color = 'Office', node_size = 'Seniority')") &
theme(plot.subtitle = element_text(size = 8))
```
#### More layouts
`{manynet}` can use all the layout algorithms offered by packages such as `{igraph}`, `{ggraph}`, and `{graphlayouts}`,
and offers some additional layout algorithms for
snapping layouts to a grid,
visualising partitions horizontally, vertically, or concentrically,
or conforming to configurational coordinates.
<img src="https://www.jameshollway.com/post/manynet/README-more-layouts-1.png" alt="Graphs illustrating different layouts"/>
```{r more-layouts, echo = FALSE, message=FALSE, dpi = 250, eval=FALSE}
(graphr(ison_southern_women, layout = "concentric") + ggtitle("Concentric layout")) /
((graphr(to_unnamed(create_explicit(A-+B-+C, A-+C))) + ggtitle("Triad layout")) |
(graphr(to_unnamed(create_explicit(A-+C, A-+D, B-+C, B-+D))) + ggtitle("Quad layout")))
```
#### More themes and scales
Lastly, `graphr()` is highly extensible in terms of the overall look of your plots.
`{manynet}` uses the excellent `{ggraph}` package (and thus `{ggplot2}`)
as a plotting engine.
This enables alterations such as the application of themes to be applied upon the defaults.
If you want to quickly make sure your plots conform to your institution or taste,
then it is easy to do with themes and scales that update the basic look and color palette
used in your plots.
<img src="https://www.jameshollway.com/post/manynet/README-more-themes-1.png" alt="Graphs using default, IHEID, and ETHZ themes"/>
```{r more-themes, echo = FALSE, message=FALSE, dpi = 300, fig.height=3, eval=FALSE}
p <- graphr(ison_lawfirm, node_color = "Practice") +
ggtitle("Original")
p + p + theme_iheid() + scale_color_iheid() +
ggtitle("Graduate Institute", subtitle = "_iheid") +
p + theme_ethz() + scale_color_ethz() +
ggtitle("ETH Zürich", subtitle = "_ethz") & ggplot2::theme(legend.position = "none")
```
More themes are on their way, and we're happy to take suggestions.
### graphs
Second, `graphs()` is used to graph multiple networks together,
which can be useful for ego networks or network panels.
`{patchwork}` is used to help arrange individual plots together.
<img src="https://www.jameshollway.com/post/manynet/README-autographs-1.png" alt="Example of graphs() used on longitudinal data"/>
```{r autographs, echo = FALSE, dpi = 250, fig.height=3, eval=FALSE}
ison_adolescents %>%
mutate_ties(wave = c(rep(1995, 5), rep(1998, 5))) %>%
to_waves(attribute = "wave", panels = c(1995, 1998)) %>%
graphs()
```
### grapht
Third, `grapht()` is used to visualise dynamic networks.
It uses `{gganimate}` and `{gifski}` to create a gif that
visualises network changes over time.
It really couldn't be easier.
<img src="https://www.jameshollway.com/post/manynet/README-autographd-1.gif" alt="Example of grapht() on longitudinal data"/>
```{r autographd, echo = FALSE, dpi = 250, fig.height=3.5, eval=FALSE}
ison_adolescents %>%
mutate_ties(year = sample(1995:1998, 10, replace = TRUE)) %>%
to_waves(attribute = "year") %>%
grapht()
```
<!-- provide a common set of tools that can be used to import, export, create, and manipulate network data in a wide variety of formats, -->
<!-- and obtain a good first visualisation quickly. -->
<!-- This can be useful for pedagogical purposes, initial description, or checking something part way through the modelling process. -->
<!-- Through the most comprehensive network class-coercion available, -->
<!-- users can access routines not available in their chosen package or even in `{manynet}`. -->
<!-- `{manynet}` provides a common set of tools and a standard syntax for analysing many different types of networks. -->
<!-- It offers a broad range of functions to make, manipulate, map, measure, and model: -->
<!-- - one-, two-, and sometimes three-mode networks -->
<!-- - undirected, directed, and sometimes complex networks -->
<!-- - unweighted, weighted, and sometimes signed networks -->
## Marking
`{manynet}` includes four special groups of functions,
each with their own pretty `print()` and `plot()` methods:
marks, measures, motifs, and memberships.
Marks are logical scalars or vectors, measures are numeric,
memberships categorical, and motifs result in tabular outputs.
`{manynet}`'s `*is_*()` functions offer fast logical tests of various properties.
Whereas `is_*()` returns a single logical value for the network,
`node_is_*()` returns a logical vector the length of the number of nodes in the network,
and `tie_is_*()` returns a logical vector the length of the number of ties in the network.
- `r list_functions("^is_")`
- `r list_functions("^node_is_")`
- `r list_functions("^tie_is_")`
The `*is_max()` and `*is_min()` functions are used to identify
the maximum or minimum, respectively, node or tie according to some measure (see below).
## Motifs
`{manynet}`'s `*by_*()` functions tabulate nodes' frequency in various motifs.
These include:
- `r list_functions("_by_")`
## Memberships
`{manynet}`'s `*in_*()` functions identify nodes' membership in some grouping,
such as a community or component.
These functions always return a character vector,
indicating e.g. that the first node is a member of group "A", the second in group "B", etc.
- `r list_functions("_in_")`
For example `node_brokerage_census()` returns
the frequency of nodes' participation in
Gould-Fernandez brokerage roles for a one-mode network,
and the Jasny-Lubell brokerage roles for a two-mode network.
These can be analysed alone, or used as a profile for establishing equivalence.
`{manynet}` offers both HCA and CONCOR algorithms,
as well as elbow, silhouette, and strict methods for _k_-cluster selection.
<img src="https://www.jameshollway.com/post/migraph/dendroPlot.png" alt="Plot of a dendrogram of structural equivalence"/>
`{manynet}` also includes functions for establishing membership on other bases,
such as typical community detection algorithms,
as well as component and core-periphery partitioning algorithms.
## Measuring
`{manynet}` also offers a large and growing smorgasbord of measures that
can be used at the node, tie, and network level
to measure some feature, property, or quantity of the network.
Each recognises whether the network is directed or undirected,
weighted or unweighted, one-mode or two-mode.
All return normalized values wherever possible,
though this can be overrided.
Here are some examples:
- _Centrality_: `node_degree()`, `node_closeness()`, `node_betweenness()`, and `node_eigenvector()`,
`net_degree()`, `net_closeness()`, `net_betweenness()`, and `net_eigenvector()`
- _Cohesion_: `net_density()`, `net_reciprocity()`, `net_transitivity()`, `net_equivalency()`, and `net_congruency()`
- _Hierarchy_: `net_connectedness()`, `net_efficiency()`, `net_upperbound()`
- _Resilience_: `net_components()`, `net_cohesion()`, `net_adhesion()`, `net_diameter()`, `net_length()`
- _Innovation_: e.g. `node_redundancy()`, `node_effsize()`, `node_efficiency()`, `node_constraint()`, `node_hierarchy()`
- _Diversity_: `net_richness()`, `net_diversity()`, `net_heterophily()`, `net_assortativity()`,
`node_richness()`, `node_diversity()`, `node_heterophily()`, `node_assortativity()`
- _Topology_: e.g. `net_core()`, `net_factions()`, `net_modularity()`, `net_smallworld()`, `net_balance()`
- _Diffusion_: e.g. `net_reproduction()`, `net_immunity()`, `node_thresholds()`
There is a lot here,
so we recommend you explore [the list of functions](https://stocnet.github.io/migraph/reference/index.html) to find out more.
## Tutorials
This package includes tutorials to help new and experienced users
learn how they can conduct social network analysis using the package.
These tutorials leverage the additional package `{learnr}` (see [here](https://rstudio.github.io/learnr/)),
but we have made it easy to use `{manynet}` or `{migraph}` tutorials
right out of the box:
```{r learnr-tutes}
run_tute()
# run_tute("tutorial1")
```
## Installation
### Stable
The easiest way to install the latest stable version of `{manynet}` is via CRAN.
Simply open the R console and enter:
`install.packages('manynet')`
`library(manynet)` will then load the package and make the data and tutorials (see below) contained within the package available.
### Development
For the latest development version,
for slightly earlier access to new features or for testing,
you may wish to download and install the binaries from Github
or install from source locally.
The latest binary releases for all major OSes -- Windows, Mac, and Linux --
can be found [here](https://github.com/stocnet/manynet/releases/latest).
Download the appropriate binary for your operating system,
and install using an adapted version of the following commands:
- For Windows: `install.packages("~/Downloads/manynet_winOS.zip", repos = NULL)`
- For Mac: `install.packages("~/Downloads/manynet_macOS.tgz", repos = NULL)`
- For Unix: `install.packages("~/Downloads/manynet_linuxOS.tar.gz", repos = NULL)`
To install from source the latest main version of `{manynet}` from Github,
please install the `{remotes}` package from CRAN and then:
- For latest stable version:
`remotes::install_github("stocnet/manynet")`
- For latest development version:
`remotes::install_github("stocnet/manynet@develop")`
### Other sources
Those using Mac computers may also install using Macports:
`sudo port install R-manynet`
## Relationship to other packages
This package stands on the shoulders of several incredible packages.
In terms of the objects it works with,
this package aims to provide an updated, more comprehensive replacement for `{intergraph}`.
As such it works with objects in `{igraph}` and `{network}` formats,
but also equally well with base matrices and edgelists (data frames),
and formats from several other packages.
The user interface is inspired in some ways by Thomas Lin Pedersen's excellent `{tidygraph}` package,
though makes some different decisions,
and uses the quickest `{igraph}` or `{network}` routines where available.
`{manynet}` has inherited most of its core functionality from its maternal package, `{migraph}`.
`{migraph}` continues to offer more analytic and modelling functions that builds upon
the architecture provided by `{manynet}`.
For more, please check out `{migraph}` directly.
## Funding details
Development on this package has been funded by the Swiss National Science Foundation (SNSF)
[Grant Number 188976](https://data.snf.ch/grants/grant/188976):
"Power and Networks and the Rate of Change in Institutional Complexes" (PANARCHIC).