diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 0fd5a96b8..986e83d0e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -26,6 +26,19 @@ The GitHub page allows to access the issues assigned to you and check the commit You can also access the documents in the repository, although this won't be necessary after you have cloned it on your computer via Fork. +### Identifying issues + +Please use the issues tracker on GitHub to identify any function-related issues. +You can use these issues to track progress on the issue and +to comment or continue a conversation on that issue. +The most useful issues are ones that precisely identify an error, +or propose a test that should pass but instead fails. +Examples for documentation are also most welcome. + +Issues that belong to another package in the family should be transferred there +rather than fixed here: `gh issue transfer stocnet/`. +See the division of labour below. + ### Cloning Once you have downloaded Fork, the first thing you have to do is to @@ -88,7 +101,8 @@ Division of labour to keep in mind when adding functions: at the node, tie, and network level. - `{autograph}`: drawing graphs and plotting analytic, modelling, or diagnostic results, along with deep (often institutional) theming. *All* plot methods should live there. -- `{migraph}` (this package): testing and modelling, e.g. CUG/QAP/MRQAP and diffusion models. +- `{migraph}` (this package): testing and modelling, e.g. CUG/QAP/MRQAP and diffusion models, + and the `mpn_*` datasets. ### Style @@ -97,6 +111,12 @@ To that end, we have a regular syntax that users can rely on producing expected Functions in the same family (`test_*()`, `over_*()`, etc.) should share argument order and naming, so that behaviour is guessable across the family. +When writing documentation or NEWS items, prefer breaking lines at punctuation. + +Make it clear when you are referring to functions by adding backticks and parentheses, +e.g. `a_function()`, and arguments by adding an equals sign, e.g. `argument=`. +Argument values or variables can be in double quotation marks, e.g. "value". + ### Common commands This is a standard R package developed with `devtools`/`roxygen2`. @@ -183,6 +203,46 @@ versions rather than by changing `migraph`'s own code — see `cran-comments.md` guard such code paths with the `thisRequires()` helper in [R/migraph-package.R](../R/migraph-package.R), which prompts to install on first use. +### Datasets + +The `mpn_*` datasets accompany *Multimodal Political Networks*. +They are the part of this package that will remain after the inferential +functions move, so their conventions matter. + +**Naming.** Lower case throughout, with no capitals: +`mpn_evs_ita`, not `mpn_IT`. +Group by source, then narrow: `mpn_evs_*`, `mpn_cow_*`, `mpn_elite_*`. +Use the ISO three-letter code for a country. + +**Class.** Every dataset is a `stocnet` object. +Build one as a list with the slots `info`, `nodes`, `ties`, `changes`, `globals`, +and `missings` where there are unobserved dyads. + +| Slot | Holds | +|---|---| +| `nodes$label` | the node name | +| `nodes$mode` | a **character** name for each set of nodes, two or more values | +| `ties$layer` | a character name for each tie type | +| `ties$time` | the observation time | +| `missings` | unobserved dyads, kept out of `ties` | +| `info` | provenance, written with `manynet::add_info()` | + +Two traps when converting. +`manynet::as_stocnet()` writes `nodes$mode` as the strings `"FALSE"` and `"TRUE"`, +so rewrite it with real names. +It also drops the `grand` graph attribute, so restore the title with `add_info()`. + +**Provenance.** Record what the source states, and nothing more. +`add_info()` recognises `name`, `modes`, `layers`, `directed`, `source`, `method`, +`location`, `date`, `boundary`, `observation`, `update`, and `doi`. +Do not invent a `method`, `boundary`, or `doi` that cannot be checked against +the documentation or the cited source. + +**Missing data.** Record an unobserved dyad in `missings`, never as a zero tie +and never as a source's numeric code. +`mpn_cow_trade` once stored the Correlates of War code `-9` as a negative weight, +which made the network read as signed. + ### Tests This package uses the `testthat` package for testing functions. diff --git a/.github/workflows/pushrelease.yml b/.github/workflows/pushrelease.yml index 2c176002b..dd8569909 100644 --- a/.github/workflows/pushrelease.yml +++ b/.github/workflows/pushrelease.yml @@ -107,12 +107,26 @@ jobs: echo "Renamed files" ls migraph_* + - name: Extract release notes from NEWS.md + shell: bash + run: | + # Take the NEWS.md section for this version, else the topmost section. + awk -v ver="${{ env.PACKAGE_NAME }} ${{ env.PACKAGE_VERSION }}" ' + /^# / { if (found) exit; if (substr($0, 3) == ver) { found = 1; next } } + found { print } + ' NEWS.md > RELEASE_NOTES.md + if [ ! -s RELEASE_NOTES.md ]; then + awk 'NR > 1 && /^# / { exit } NR > 1 { print }' NEWS.md > RELEASE_NOTES.md + fi + cat RELEASE_NOTES.md + - name: Create Release and Upload Assets id: create_release uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.newtag.outputs.tag }} name: Release ${{ steps.newtag.outputs.tag }} + body_path: RELEASE_NOTES.md draft: false prerelease: false fail_on_unmatched_files: true diff --git a/DESCRIPTION b/DESCRIPTION index d6fe876e6..b802b39ff 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: migraph Title: Inferential Methods for Multimodal and Other Networks -Version: 1.6.9 +Version: 1.7.0 Description: A set of tools for testing networks. It includes functions for univariate and multivariate conditional uniform graph and quadratic assignment procedure testing, and network regression. @@ -18,8 +18,8 @@ Encoding: UTF-8 LazyData: true Depends: R (>= 4.1.0), - manynet (>= 2.2.1), - autograph (>= 1.1.1), + manynet (>= 2.3.1), + autograph (>= 1.2.2), netrics (>= 0.4.0) Imports: dplyr (>= 1.1.0), diff --git a/NEWS.md b/NEWS.md index 445be3f16..a099832c9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,55 @@ +# migraph 1.7.0 + +## Package + +- Raised the minimum versions of the stocnet dependencies: manynet 2.3.1 and autograph 1.2.2 +- Updated CONTRIBUTING +- Fixed the attach-time version check by parsing version strings with `package_version()` + +## Models + +- Fixed `play_diffusions()` for `stocnet` input via initial coercion (re stocnet/manynet#172) + +## Data + +- Converted every `mpn_*` dataset to the `stocnet` class, in line with `{manynet}` +- Removed the `weight` tie attribute from the datasets that are not weighted +- Merged `mpn_cow` + - This combines interstate trade and IGO membership into one multilevel network + of 116 "states" and 40 "IGOs", with `trade` and `membership` tie layers + - `mpn_cow_trade` and `mpn_cow_igo` are retained, because `{manynet}` currently + reads a network with two named modes as undirected, which symmetrises the + trade layer of `mpn_cow`, and because `to_layer()` does not recover that layer + either (stocnet/manynet#170, stocnet/manynet#171) + - Fixed `mpn_cow_trade` missing-data coding from `-9` (759 cells) to `NA` + - Added a `scope` node attribute to the IGOs in `mpn_cow` and `mpn_cow_igo`, + recording whether an organisation is `"global"` or `"regional"` +- Merged `mpn_senate` + - This combines the 112th Congress data into one multilevel network + of 93 senators, 78 PACs, and 25 bills + - `mpn_senate_dem` and `mpn_senate_rep` are not party networks but + record two communities of one network and their intersection; + the `community` node attribute holds `"A"`, `"B"`, or `"both"` + - Cells that neither community covers were never observed, and are recorded as + missing rather than as absent ties + - Where the two communities disagree, in 9 of their 640 shared cells, + community A governs, since it agrees with the overlap file in all 640 + - `mpn_senate_dem`, `mpn_senate_rep`, and `mpn_senate_over` are deprecated and + will be removed in 1.8.0 +- Merged `mpn_evs_ita`, `mpn_evs_deu`, and `mpn_evs_gbr` + - These combine each country's European Values Study data for 1990 and 2008 into one two-mode network, + with the year recorded in the `time` tie attribute + - These are repeated cross-sections, not a panel, so use `over_time()` not `over_waves()` + - The six year-by-country datasets are deprecated and will be removed in 1.8.0 +- Converted `mpn_elite_mex` +- Converted `mpn_elite_usa_advice` + - It now names its two modes, `"directors"` and `"think tanks"` +- Converted `mpn_elite_usa_money` + - It now names its three modes, `"elites"`, `"organisations"`, and `"candidates"` +- Converted `mpn_bristol` + - It now names its three modes, `"individuals"`, `"organisations"`, and `"events"` +- Converted `mpn_ryanair` + # migraph 1.6.9 ## Package diff --git a/R/data_mpn.R b/R/data_mpn.R index 735ef2236..3c4df99f3 100644 --- a/R/data_mpn.R +++ b/R/data_mpn.R @@ -181,9 +181,52 @@ # Senate voting #### +#' Multilevel 112th Congress Senate network (Knoke et al. 2021) +#' +#' @description +#' `mpn_senate` combines the two community networks of the 112th Congress into +#' one multilevel network of 93 senators, 78 political action committees (PACs), +#' and 25 key bills. +#' The `mode` node attribute separates the three sets of nodes. +#' +#' `mpn_senate_dem` and `mpn_senate_rep` are not party networks. +#' The source files are named `Fig8.1_SxPV_CommA`, `Fig8.2_SxPV_CommB`, and +#' `Fig8.3_SxPV_Overlap`, so they record two communities of one network and +#' their intersection. +#' The `community` node attribute holds `"A"`, `"B"`, or `"both"`. +#' The 20 senators and 32 PACs and bills marked `"both"` reproduce `mpn_senate_over`. +#' +#' @details +#' Two points of care. +#' +#' Cells that neither community covers were never observed. +#' They are recorded as missing rather than as absent ties, +#' so the object holds 2542 missing dyads. +#' +#' The two communities overlap in 640 cells and disagree in 9 of them. +#' Community A governs those cells: +#' it agrees with `Fig8.3_SxPV_Overlap` in all 640, where community B differs in 9. +#' @docType data +#' @keywords datasets +#' @name mpn_senate +#' @usage data(mpn_senate) +#' @references +#' Knoke, David, Mario Diani, James Hollway, and Dimitris C Christopoulos. 2021. +#' \href{https://www.cambridge.org/core/books/multimodal-political-networks/43EE8C192A1B0DCD65B4D9B9A7842128}{\emph{Multimodal Political Networks}}. +#' Cambridge University Press. Cambridge University Press. +#' @format +#' ```{r, echo = FALSE} +#' mpn_senate +#' ``` +"mpn_senate" + #' Two-mode 112th Congress Senate Voting (Knoke et al. 2021) #' #' @description +#' `r "Superseded."` These three datasets are superseded by [mpn_senate], +#' which holds the same data as one multilevel network with a `community` +#' node attribute. They are kept for one release and will be removed in 1.8.0. +#' #' These datasets list the U.S. Senators who served in the 112th Congress, #' which met from January 3, 2011 to January 3, 2013. #' Although the Senate has 100 seats, 103 persons served during this period due @@ -235,8 +278,70 @@ # EVS #### +#' Longitudinal two-mode European Values Study, 1990 and 2008 (EVS 2020) +#' +#' @description +#' `mpn_evs_ita`, `mpn_evs_deu`, and `mpn_evs_gbr` each hold one country's European Values Study +#' data for 1990 and 2008 in a single two-mode network. +#' Respondents form the first mode and the 14 types of association form the second. +#' The `time` tie attribute records the year, either 1990 or 2008. +#' +#' Italy has 1198 respondents, Germany 1872, and the United Kingdom 1402. +#' +#' @details +#' These are repeated cross-sections, not a panel. +#' The European Values Study draws a new sample each round, +#' so no respondent appears in both years. +#' +#' Use `over_time()` rather than `over_waves()` on these objects. +#' `over_time()` restricts each year to the respondents sampled in it. +#' `over_waves()` keeps the whole node set in each wave, +#' which understates the density of each year. +#' +#' ```r +#' over_time(mpn_evs_ita, netrics::net_by_density, attribute = "time") +#' ``` +#' @docType data +#' @keywords datasets +#' @name mpn_evs_combined +#' @usage data(mpn_evs_ita) +#' @source Knoke, David, Mario Diani, James Hollway, and Dimitris C Christopoulos. 2021. +#' \href{https://www.cambridge.org/core/books/multimodal-political-networks/43EE8C192A1B0DCD65B4D9B9A7842128}{\emph{Multimodal Political Networks}}. +#' Cambridge University Press. Cambridge University Press. +#' @references +#' EVS (2020). European Values Study Longitudinal Data File 1981-2008 (EVS 1981-2008). +#' GESIS Data Archive, Cologne. ZA4804 Data file Version 3.1.0, +#' \doi{10.4232/1.13486}. +#' @format +#' ```{r, echo = FALSE} +#' mpn_evs_ita +#' ``` +"mpn_evs_ita" + +#' @rdname mpn_evs_combined +#' @usage data(mpn_evs_deu) +#' @format +#' ```{r, echo = FALSE} +#' mpn_evs_deu +#' ``` +"mpn_evs_deu" + +#' @rdname mpn_evs_combined +#' @usage data(mpn_evs_gbr) +#' @format +#' ```{r, echo = FALSE} +#' mpn_evs_gbr +#' ``` +"mpn_evs_gbr" + #' Two-mode European Values Survey, 1990 and 2008 (EVS 2020) #' +#' @description +#' `r "Superseded."` These six datasets are superseded by [mpn_evs_ita], [mpn_evs_deu], +#' and [mpn_evs_gbr], which hold the same data as one longitudinal network for each +#' country. They are kept for one release and will be removed in 1.8.0. +#' +#' @details #' 6 two-mode matrices containing individuals' memberships to 14 different types #' of associations in three countries (Italy, Germany, and the UK) in 1990 #' and 2008. The Italy data has 658 respondents in 1990 and 540 in 2008. @@ -298,8 +403,78 @@ NULL # COW #### +#' Multilevel state trade and IGO membership network (COW) +#' +#' @description +#' `mpn_cow` combines interstate trade and membership in intergovernmental +#' organisations (IGOs) into a single multilevel network of 116 states and 40 IGOs. +#' It holds two tie layers: +#' \describe{ +#' \item{trade}{directed, weighted ties among the states, in 2009} +#' \item{membership}{undirected ties from states to the 40 IGOs} +#' } +#' The `mode` node attribute separates the `"states"` from the `"IGOs"`. +#' The `polity2` node attribute is carried over for the states, and the `scope` +#' node attribute records whether an IGO is `"global"` or `"regional"`. +#' Seven are global: IOMig, OECD, OIC, OPEC, OSCE, UN, and WTO. +#' Four states appear in the trade data but not in the IGO data: +#' Bosnia and Herzegovina, Iceland, Lebanon, and Brunei. +#' Their `polity2` value is `NA`. +#' +#' @details +#' The `scope` attribute recovers a distinction that earlier releases stored, +#' misleadingly, as a tie `weight` on the membership relation. +#' No organisation held both values, so the attribute belongs to the IGOs and not +#' to their ties. The zeros were never absent ties: the only state with no UN tie +#' is Taiwan, so reading a zero as an absence would invert the membership of +#' every global body. +#' +#' The Correlates of War Trade dataset codes missing trade values as `-9`. +#' These 759 cells are recorded as missing rather than as negative trade values, +#' so they appear in the object's Missings table and not among its ties. +#' Earlier releases stored them as `-9`, which made the network read as signed. +#' +#' Note two current limitations of `{manynet}`. +#' A network with exactly two named modes is treated as two-mode, and therefore +#' as undirected, so `as_matrix(mpn_cow)` returns a symmetrised trade layer. +#' `to_layer(mpn_cow, "trade")` does not recover it either, because it maps +#' the two ends of each arc to the wrong nodes. +#' The ties stored in the object are complete and correctly directed. +#' Until both are resolved, use `mpn_cow_trade` for any matrix-level analysis of trade. +#' See stocnet/manynet#170 and stocnet/manynet#171. +#' @docType data +#' @keywords datasets +#' @name mpn_cow_combined +#' @usage data(mpn_cow) +#' @references +#' Barbieri, Katherine, Omar M. G. Keshk, and Brian Pollins. 2009. +#' “TRADING DATA: Evaluating our Assumptions and Coding Rules.” +#' _Conflict Management and Peace Science_ 26(5): 471-491. +#' \doi{10.1177/0738894209343887}. +#' +#' Pevehouse, Jon C.W., Timothy Nordstrom, Roseanne W McManus, Anne Spencer Jamison. 2020. +#' “Tracking Organizations in the World: The Correlates of War IGO Version 3.0 datasets”. +#' _Journal of Peace Research_ 57(3): 492-503. +#' \doi{10.1177/0022343319881175}. +#' +#' Knoke, David, Mario Diani, James Hollway, and Dimitris C Christopoulos. 2021. +#' \href{https://www.cambridge.org/core/books/multimodal-political-networks/43EE8C192A1B0DCD65B4D9B9A7842128}{\emph{Multimodal Political Networks}}. +#' Cambridge University Press. Cambridge University Press. +#' @format +#' ```{r, echo = FALSE} +#' mpn_cow +#' ``` +"mpn_cow" + #' One-mode interstate trade relations and two-mode state membership in IGOs (COW) #' +#' @description +#' [mpn_cow] combines these two datasets into one multilevel network. +#' They are kept alongside it because `{manynet}` currently reads a network with +#' two named modes as undirected, which symmetrises the trade layer of `mpn_cow`, +#' and because `to_layer()` does not recover that layer either. +#' See stocnet/manynet#170 and stocnet/manynet#171. +#' #' @details #' `mpn_cow_trade` is a one-mode matrix representing the trade relations between 116 states. #' The data is derived from the Correlates of War Project (COW) Trade Dataset (v3.0), @@ -322,7 +497,7 @@ NULL #' with 116 states listed in Appendix 7.1 in \href{https://www.cambridge.org/core/books/multimodal-political-networks/43EE8C192A1B0DCD65B4D9B9A7842128}{\emph{Multimodal Political Networks}} #' and 40 IGOs from Table 7.1 in \href{https://www.cambridge.org/core/books/multimodal-political-networks/43EE8C192A1B0DCD65B4D9B9A7842128}{\emph{Multimodal Political Networks}} #' that also overlap with the COW dataset (Knoke et al., 2021). -#' @name mpn_cow +#' @name mpn_cow_separate #' @docType data #' @keywords datasets #' @usage data(mpn_cow_trade) @@ -346,7 +521,7 @@ NULL #' ``` "mpn_cow_trade" -#' @rdname mpn_cow +#' @rdname mpn_cow_separate #' @usage data(mpn_cow_igo) #' @source #' The Correlates of War Project. 2019. \emph{Intergovernmental Organization v3}. diff --git a/R/model_diffusion.R b/R/model_diffusion.R index 200d3ebe5..f0cd0cfc9 100644 --- a/R/model_diffusion.R +++ b/R/model_diffusion.R @@ -7,6 +7,7 @@ #' \item igraph, from the `{igraph}` package #' \item network, from the `{network}` package #' \item tbl_graph, from the `{tidygraph}` package +#' \item stocnet, from the `{manynet}` package #' } #' @param ... Other parameters inherited from `manynet::play_diffusion()`. #' @param times Integer indicating number of simulations. @@ -30,6 +31,11 @@ play_diffusions <- function(.data, oplan <- future::plan(strategy) on.exit(future::plan(oplan), add = TRUE) + # `manynet::play_diffusion()` calls `igraph::neighborhood()` on `.data` directly, + # so it stops on a stocnet object, including `{manynet}`'s own stocnet datasets. + # Coerce here until that is fixed upstream. + if (inherits(.data, "stocnet")) .data <- manynet::as_igraph(.data) + out <- furrr::future_map_dfr(1:times, function(j){ data.frame(sim = j, manynet::as_diffusion(manynet::play_diffusion(.data, ...))) diff --git a/R/zzz.R b/R/zzz.R index 325200768..a6661e4b8 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -74,27 +74,55 @@ snet_github_versions <- function() { }, error = function(e) NULL, warning = function(w) NULL) } +# nocov end + # Which packages are behind, and where the newer version lives. When CRAN and # GitHub agree, prefer CRAN: it is the binary install and needs no compiler. -snet_check_versions <- function() { - cran <- snet_cran_versions() - gh <- snet_github_versions() +# +# `cran`, `gh` and `installed` are arguments rather than direct calls so that +# this comparison can be tested without a network. Everything around it either +# reaches the network or runs only on an interactive attach, so it is the one +# part that a test can reach. +snet_check_versions <- function(cran = snet_cran_versions(), + gh = snet_github_versions(), + installed = snet_installed_versions()) { if (is.null(cran) && is.null(gh)) return(NULL) out <- list() for (p in snet_pkgs) { - installed <- tryCatch(utils::packageVersion(p), error = function(e) NULL) - if (is.null(installed)) next - cv <- if (!is.null(cran) && p %in% names(cran)) utils::packageVersion(cran[[p]]) else NULL - gv <- if (!is.null(gh) && p %in% names(gh)) utils::packageVersion(gh[[p]]) else NULL - if (!is.null(cv) && cv > installed) { + iv <- installed[[p]] + if (is.null(iv) || is.na(iv)) next + iv <- package_version(iv) + # These are version strings read from a repository, so they are parsed with + # `package_version()`. `utils::packageVersion()` takes a package *name* and + # looks up what is installed, so passing a version string to it fails with + # "there is no package called '1.6.8'". + cv <- if (!is.null(cran) && p %in% names(cran)) snet_as_version(cran[[p]]) else NULL + gv <- if (!is.null(gh) && p %in% names(gh)) snet_as_version(gh[[p]]) else NULL + if (!is.null(cv) && cv > iv) { out[[p]] <- list(version = as.character(cv), source = "CRAN") - } else if (!is.null(gv) && gv > installed) { + } else if (!is.null(gv) && gv > iv) { out[[p]] <- list(version = as.character(gv), source = "GitHub") } } out } +# A repository can return something that is not a version, so never let a bad +# string reach the user as an error on attach. +snet_as_version <- function(x) { + if (is.null(x) || is.na(x) || !nzchar(x)) return(NULL) + tryCatch(package_version(x), error = function(e) NULL, warning = function(w) NULL) +} + +# nocov start + +snet_installed_versions <- function() { + out <- lapply(snet_pkgs, function(p) + tryCatch(as.character(utils::packageVersion(p)), error = function(e) NULL)) + names(out) <- snet_pkgs + out +} + snet_report_outdated <- function(behind) { if (!length(behind)) return(invisible(NULL)) pkgs <- names(behind) diff --git a/cran-comments.md b/cran-comments.md index 31b9e985b..af63ff024 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -9,14 +9,44 @@ 0 errors | 0 warnings | 0 notes +## Reverse dependency check of netrics 1.0.1 + +The submission of `{netrics}` 1.0.1 reported one test failure in the CRAN version of `{migraph}`: + +``` +── Failure ('test-measure_over.R:9:3'): over_membership works ── +Expected `unname(unlist(c(res)))` to equal `c(0.490201713, NaN)`. +``` + +This version replaces that test with a fixed network and an explicit membership vector, +so it no longer depends on any upstream clustering method. + +This submission is therefore what unblocks `{netrics}` 1.0.1, +and it deliberately does not require it. +`{migraph}` declares `netrics (>= 0.4.0)`, the version currently on CRAN, +so this package can be accepted before `{netrics}` 1.0.1 is. +It checks cleanly against both: + +| `{netrics}` | R CMD check | +|---|---| +| 0.4.0, the version on CRAN | 0 errors, 0 warnings, 0 notes | +| 1.0.1, the pending submission | 0 errors, 0 warnings, 0 notes | + +`{migraph}` calls six `{netrics}` functions. +All six are exported by both versions and return identical values. + ## User filespace and internet access -On attach in interactive sessions only, this version checks whether the installed stocnet packages -are outdated, and caches the result for seven days in `tools::R_user_dir("migraph", "cache")`. This -replaces a check that previously ran on every attach in each of three dependencies, so it reduces -both network use and startup time. +On attach in interactive sessions only, +this version checks whether the installed stocnet packages are outdated, +and caches the result for seven days in `tools::R_user_dir("migraph", "cache")`. +This replaces a check that previously ran on every attach in each of three dependencies, +so it reduces both network use and startup time. -The check queries CRAN and the packages' public GitHub repositories. It is wrapped in `tryCatch()` -with a short timeout, fails silently when offline or when no repository is configured, is skipped -entirely in non-interactive sessions, and can be disabled with `options(snet_check_version = FALSE)`. +The check queries CRAN and the packages' public GitHub repositories. +It is wrapped in `tryCatch()` with a short timeout, +fails silently when offline or when no repository is configured, +is skipped entirely in non-interactive sessions, +and can be disabled with `options(snet_check_version = FALSE)`. The package is fully functional if the cache directory is absent or unwritable. + diff --git a/data/mpn_DE_1990.rda b/data/mpn_DE_1990.rda index 027a093b9..2f5fbdf2b 100644 Binary files a/data/mpn_DE_1990.rda and b/data/mpn_DE_1990.rda differ diff --git a/data/mpn_DE_2008.rda b/data/mpn_DE_2008.rda index 2d3d48952..4f132b7fa 100644 Binary files a/data/mpn_DE_2008.rda and b/data/mpn_DE_2008.rda differ diff --git a/data/mpn_IT_1990.rda b/data/mpn_IT_1990.rda index 3930477c3..52763052d 100644 Binary files a/data/mpn_IT_1990.rda and b/data/mpn_IT_1990.rda differ diff --git a/data/mpn_IT_2008.rda b/data/mpn_IT_2008.rda index 6799669a4..0ea86501b 100644 Binary files a/data/mpn_IT_2008.rda and b/data/mpn_IT_2008.rda differ diff --git a/data/mpn_UK_1990.rda b/data/mpn_UK_1990.rda index 962795abd..6d5fefccd 100644 Binary files a/data/mpn_UK_1990.rda and b/data/mpn_UK_1990.rda differ diff --git a/data/mpn_UK_2008.rda b/data/mpn_UK_2008.rda index 2b75b48a2..cdae0c79d 100644 Binary files a/data/mpn_UK_2008.rda and b/data/mpn_UK_2008.rda differ diff --git a/data/mpn_bristol.rda b/data/mpn_bristol.rda index ad78184a4..3d9aa3baa 100644 Binary files a/data/mpn_bristol.rda and b/data/mpn_bristol.rda differ diff --git a/data/mpn_cow.rda b/data/mpn_cow.rda new file mode 100644 index 000000000..8cca8c6a8 Binary files /dev/null and b/data/mpn_cow.rda differ diff --git a/data/mpn_cow_igo.rda b/data/mpn_cow_igo.rda index 273f3caf5..d86324157 100644 Binary files a/data/mpn_cow_igo.rda and b/data/mpn_cow_igo.rda differ diff --git a/data/mpn_cow_trade.rda b/data/mpn_cow_trade.rda index fbd5b35ee..b4ea7ce7f 100644 Binary files a/data/mpn_cow_trade.rda and b/data/mpn_cow_trade.rda differ diff --git a/data/mpn_elite_mex.rda b/data/mpn_elite_mex.rda index efcba763a..25ada477f 100644 Binary files a/data/mpn_elite_mex.rda and b/data/mpn_elite_mex.rda differ diff --git a/data/mpn_elite_usa_advice.rda b/data/mpn_elite_usa_advice.rda index 6f5dc5add..70d11f088 100644 Binary files a/data/mpn_elite_usa_advice.rda and b/data/mpn_elite_usa_advice.rda differ diff --git a/data/mpn_elite_usa_money.rda b/data/mpn_elite_usa_money.rda index 317c74ce8..6b62640ab 100644 Binary files a/data/mpn_elite_usa_money.rda and b/data/mpn_elite_usa_money.rda differ diff --git a/data/mpn_evs_deu.rda b/data/mpn_evs_deu.rda new file mode 100644 index 000000000..ef897a11c Binary files /dev/null and b/data/mpn_evs_deu.rda differ diff --git a/data/mpn_evs_gbr.rda b/data/mpn_evs_gbr.rda new file mode 100644 index 000000000..51749d178 Binary files /dev/null and b/data/mpn_evs_gbr.rda differ diff --git a/data/mpn_evs_ita.rda b/data/mpn_evs_ita.rda new file mode 100644 index 000000000..6c0e7cc68 Binary files /dev/null and b/data/mpn_evs_ita.rda differ diff --git a/data/mpn_ryanair.rda b/data/mpn_ryanair.rda index dddcd09f1..bbe1810f2 100644 Binary files a/data/mpn_ryanair.rda and b/data/mpn_ryanair.rda differ diff --git a/data/mpn_senate.rda b/data/mpn_senate.rda new file mode 100644 index 000000000..9e5dd295e Binary files /dev/null and b/data/mpn_senate.rda differ diff --git a/data/mpn_senate_dem.rda b/data/mpn_senate_dem.rda index 141e9c06d..e3b48e1c9 100644 Binary files a/data/mpn_senate_dem.rda and b/data/mpn_senate_dem.rda differ diff --git a/data/mpn_senate_over.rda b/data/mpn_senate_over.rda index 69b709b80..a3c43252a 100644 Binary files a/data/mpn_senate_over.rda and b/data/mpn_senate_over.rda differ diff --git a/data/mpn_senate_rep.rda b/data/mpn_senate_rep.rda index 5d82cbe9b..c39f72891 100644 Binary files a/data/mpn_senate_rep.rda and b/data/mpn_senate_rep.rda differ diff --git a/man/make_play.Rd b/man/make_play.Rd index 7ab3700f1..18897ce9e 100644 --- a/man/make_play.Rd +++ b/man/make_play.Rd @@ -21,6 +21,7 @@ play_diffusions( \item igraph, from the \code{{igraph}} package \item network, from the \code{{network}} package \item tbl_graph, from the \code{{tidygraph}} package +\item stocnet, from the \code{{manynet}} package }} \item{...}{Other parameters inherited from \code{manynet::play_diffusion()}.} diff --git a/man/mpn_bristol.Rd b/man/mpn_bristol.Rd index 06ac33437..4b1163743 100644 --- a/man/mpn_bristol.Rd +++ b/man/mpn_bristol.Rd @@ -6,19 +6,19 @@ \title{Multimodal (3) Bristol protest events, 1990-2002 (Diani and Bison 2004)} \format{ \if{html}{\out{
}}\preformatted{#> -- # Bristol protest event network --------------------------------------------- -#> # A labelled, two-mode network of 150 individuals and 114 individuals and 1496 -#> affiliation and participation ties +#> # A labelled, undirected network of 264 individuals and 1496 affiliation and +#> participation ties #> #> -- Nodes -#> # A tibble: 264 x 3 -#> name type lvl -#> -#> 1 101 FALSE 1 -#> 2 102 FALSE 1 -#> 3 103 FALSE 1 -#> 4 104 FALSE 1 -#> 5 105 FALSE 1 -#> 6 106 FALSE 1 +#> # A tibble: 264 x 2 +#> label mode +#> +#> 1 101 individuals +#> 2 102 individuals +#> 3 103 individuals +#> 4 104 individuals +#> 5 105 individuals +#> 6 106 individuals #> # i 258 more rows #> #> -- Ties diff --git a/man/mpn_cow_combined.Rd b/man/mpn_cow_combined.Rd new file mode 100644 index 000000000..f192a6afe --- /dev/null +++ b/man/mpn_cow_combined.Rd @@ -0,0 +1,107 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data_mpn.R +\docType{data} +\name{mpn_cow_combined} +\alias{mpn_cow_combined} +\alias{mpn_cow} +\title{Multilevel state trade and IGO membership network (COW)} +\format{ +\if{html}{\out{
}}\preformatted{#> -- # State trade and IGO membership network ------------------------------------ +#> # A labelled, weighted, multilevel network of 116 states and 40 IGOs and 10730 +#> trade arcs and 839 membership ties (9958 parallel) +#> +#> -- Nodes +#> # A tibble: 156 x 4 +#> label mode polity2 scope +#> +#> 1 United States of America states 10 +#> 2 Canada states 10 +#> 3 Cuba states -7 +#> 4 Dominican Republic states 8 +#> 5 Jamaica states 9 +#> 6 Trinidad and Tobago states 9 +#> # i 150 more rows +#> +#> -- Missings +#> # A tibble: 759 x 4 +#> from to weight layer +#> +#> 1 31 1 NA trade +#> 2 31 2 NA trade +#> 3 31 3 NA trade +#> 4 41 3 NA trade +#> 5 59 3 NA trade +#> 6 64 3 NA trade +#> # i 753 more rows +#> +#> -- Ties +#> # A tibble: 11,569 x 4 +#> from to weight layer +#> +#> 1 2 1 228376 trade +#> 2 4 1 3421. trade +#> 3 5 1 501 trade +#> 4 6 1 5624. trade +#> 5 7 1 178335 trade +#> 6 8 1 3379. trade +#> # i 11,563 more rows +#> +}\if{html}{\out{
}} +} +\usage{ +data(mpn_cow) +} +\description{ +\code{mpn_cow} combines interstate trade and membership in intergovernmental +organisations (IGOs) into a single multilevel network of 116 states and 40 IGOs. +It holds two tie layers: +\describe{ +\item{trade}{directed, weighted ties among the states, in 2009} +\item{membership}{undirected ties from states to the 40 IGOs} +} +The \code{mode} node attribute separates the \code{"states"} from the \code{"IGOs"}. +The \code{polity2} node attribute is carried over for the states, and the \code{scope} +node attribute records whether an IGO is \code{"global"} or \code{"regional"}. +Seven are global: IOMig, OECD, OIC, OPEC, OSCE, UN, and WTO. +Four states appear in the trade data but not in the IGO data: +Bosnia and Herzegovina, Iceland, Lebanon, and Brunei. +Their \code{polity2} value is \code{NA}. +} +\details{ +The \code{scope} attribute recovers a distinction that earlier releases stored, +misleadingly, as a tie \code{weight} on the membership relation. +No organisation held both values, so the attribute belongs to the IGOs and not +to their ties. The zeros were never absent ties: the only state with no UN tie +is Taiwan, so reading a zero as an absence would invert the membership of +every global body. + +The Correlates of War Trade dataset codes missing trade values as \code{-9}. +These 759 cells are recorded as missing rather than as negative trade values, +so they appear in the object's Missings table and not among its ties. +Earlier releases stored them as \code{-9}, which made the network read as signed. + +Note two current limitations of \code{{manynet}}. +A network with exactly two named modes is treated as two-mode, and therefore +as undirected, so \code{as_matrix(mpn_cow)} returns a symmetrised trade layer. +\code{to_layer(mpn_cow, "trade")} does not recover it either, because it maps +the two ends of each arc to the wrong nodes. +The ties stored in the object are complete and correctly directed. +Until both are resolved, use \code{mpn_cow_trade} for any matrix-level analysis of trade. +See stocnet/manynet#170 and stocnet/manynet#171. +} +\references{ +Barbieri, Katherine, Omar M. G. Keshk, and Brian Pollins. 2009. +“TRADING DATA: Evaluating our Assumptions and Coding Rules.” +\emph{Conflict Management and Peace Science} 26(5): 471-491. +\doi{10.1177/0738894209343887}. + +Pevehouse, Jon C.W., Timothy Nordstrom, Roseanne W McManus, Anne Spencer Jamison. 2020. +“Tracking Organizations in the World: The Correlates of War IGO Version 3.0 datasets”. +\emph{Journal of Peace Research} 57(3): 492-503. +\doi{10.1177/0022343319881175}. + +Knoke, David, Mario Diani, James Hollway, and Dimitris C Christopoulos. 2021. +\href{https://www.cambridge.org/core/books/multimodal-political-networks/43EE8C192A1B0DCD65B4D9B9A7842128}{\emph{Multimodal Political Networks}}. +Cambridge University Press. Cambridge University Press. +} +\keyword{datasets} diff --git a/man/mpn_cow.Rd b/man/mpn_cow_separate.Rd similarity index 68% rename from man/mpn_cow.Rd rename to man/mpn_cow_separate.Rd index 67456e528..90ca1b79b 100644 --- a/man/mpn_cow.Rd +++ b/man/mpn_cow_separate.Rd @@ -1,17 +1,18 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/data_mpn.R \docType{data} -\name{mpn_cow} -\alias{mpn_cow} +\name{mpn_cow_separate} +\alias{mpn_cow_separate} \alias{mpn_cow_trade} \alias{mpn_cow_igo} \title{One-mode interstate trade relations and two-mode state membership in IGOs (COW)} \format{ -\if{html}{\out{
}}\preformatted{#> # A labelled, weighted, directed network of 116 nodes and 11489 arcs +\if{html}{\out{
}}\preformatted{#> -- # Interstate trade network -------------------------------------------------- +#> # A labelled, weighted, directed network of 116 states and 10730 trade arcs #> #> -- Nodes #> # A tibble: 116 x 1 -#> name +#> label #> #> 1 United States of America #> 2 Canada @@ -21,8 +22,20 @@ #> 6 Trinidad and Tobago #> # i 110 more rows #> +#> -- Missings +#> # A tibble: 759 x 3 +#> from to weight +#> +#> 1 1 31 NA +#> 2 2 31 NA +#> 3 3 31 NA +#> 4 3 41 NA +#> 5 3 59 NA +#> 6 3 66 NA +#> # i 753 more rows +#> #> -- Ties -#> # A tibble: 11,489 x 3 +#> # A tibble: 10,730 x 3 #> from to weight #> #> 1 1 2 180387 @@ -31,34 +44,36 @@ #> 4 1 5 1896. #> 5 1 6 2188. #> 6 1 7 123677 -#> # i 11,483 more rows +#> # i 10,724 more rows #> }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{#> # A labelled, weighted, two-mode network of 112 nodes and 40 nodes and 839 ties +\if{html}{\out{
}}\preformatted{#> -- # State IGO membership network ---------------------------------------------- +#> # A labelled, two-mode network of 112 states and 40 IGOs and 839 membership +#> ties #> #> -- Nodes -#> # A tibble: 152 x 3 -#> name type polity2 -#> -#> 1 Afghanistan FALSE -7 -#> 2 Albania FALSE 5 -#> 3 Algeria FALSE -3 -#> 4 Angola FALSE -6 -#> 5 Argentina FALSE 8 -#> 6 Australia FALSE 10 +#> # A tibble: 152 x 4 +#> label mode polity2 scope +#> +#> 1 Afghanistan states -7 +#> 2 Albania states 5 +#> 3 Algeria states -3 +#> 4 Angola states -6 +#> 5 Argentina states 8 +#> 6 Australia states 10 #> # i 146 more rows #> #> -- Ties -#> # A tibble: 839 x 3 -#> from to weight -#> -#> 1 1 113 1 -#> 2 1 114 1 -#> 3 1 115 0 -#> 4 1 116 0 -#> 5 1 117 1 -#> 6 1 118 0 +#> # A tibble: 839 x 2 +#> from to +#> +#> 1 1 113 +#> 2 1 114 +#> 3 1 115 +#> 4 1 116 +#> 5 1 117 +#> 6 1 118 #> # i 833 more rows #> }\if{html}{\out{
}} @@ -77,7 +92,11 @@ data(mpn_cow_trade) data(mpn_cow_igo) } \description{ -One-mode interstate trade relations and two-mode state membership in IGOs (COW) +\link{mpn_cow} combines these two datasets into one multilevel network. +They are kept alongside it because \code{{manynet}} currently reads a network with +two named modes as undirected, which symmetrises the trade layer of \code{mpn_cow}, +and because \code{to_layer()} does not recover that layer either. +See stocnet/manynet#170 and stocnet/manynet#171. } \details{ \code{mpn_cow_trade} is a one-mode matrix representing the trade relations between 116 states. diff --git a/man/mpn_elite_mex.Rd b/man/mpn_elite_mex.Rd index 9e6493c32..99b7c4fc4 100644 --- a/man/mpn_elite_mex.Rd +++ b/man/mpn_elite_mex.Rd @@ -12,7 +12,7 @@ #> #> -- Nodes #> # A tibble: 35 x 8 -#> name full_name entry_year military in_mpn PlaceOfBirth state region +#> label full_name entry_year military in_mpn PlaceOfBirth state region #> #> 1 Trevino Trevino, Jacint~ 1910 1 0 Guerrero Coah~ 1 #> 2 Madero Madero, Francis~ 1911 0 0 Parras de l~ Coah~ 1 diff --git a/man/mpn_elite_usa.Rd b/man/mpn_elite_usa.Rd index 27dca211b..f0cdecac3 100644 --- a/man/mpn_elite_usa.Rd +++ b/man/mpn_elite_usa.Rd @@ -7,18 +7,20 @@ \alias{mpn_elite_usa_money} \title{Two-mode and three-mode American power elite database (Domhoff 2016)} \format{ -\if{html}{\out{
}}\preformatted{#> # A labelled, two-mode network of 14 nodes and 20 nodes and 46 ties +\if{html}{\out{
}}\preformatted{#> -- # US think tank board network ----------------------------------------------- +#> # A labelled, two-mode network of 14 directors and 20 think tanks and 46 board +#> membership ties #> #> -- Nodes #> # A tibble: 34 x 2 -#> type name -#> -#> 1 FALSE Albright -#> 2 FALSE Argyros -#> 3 FALSE Armitage -#> 4 FALSE Curry -#> 5 FALSE Fukuyama -#> 6 FALSE Gray +#> label mode +#> +#> 1 Albright directors +#> 2 Argyros directors +#> 3 Armitage directors +#> 4 Curry directors +#> 5 Fukuyama directors +#> 6 Gray directors #> # i 28 more rows #> #> -- Ties @@ -35,30 +37,32 @@ #> }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{#> # A labelled, two-mode network of 26 nodes and 12 nodes and 103 ties +\if{html}{\out{
}}\preformatted{#> -- # US power elite network ---------------------------------------------------- +#> # A labelled, multiplex, undirected network of 38 elites and 59 board +#> membership ties and 44 campaign contribution ties #> #> -- Nodes #> # A tibble: 38 x 2 -#> type name -#> -#> 1 FALSE Adkerson -#> 2 FALSE Akins -#> 3 FALSE Banga -#> 4 FALSE Boyce -#> 5 FALSE Britt -#> 6 FALSE Cannon +#> label mode +#> +#> 1 Adkerson elites +#> 2 Akins elites +#> 3 Banga elites +#> 4 Boyce elites +#> 5 Britt elites +#> 6 Cannon elites #> # i 32 more rows #> #> -- Ties -#> # A tibble: 103 x 2 -#> from to -#> -#> 1 1 27 -#> 2 1 28 -#> 3 1 34 -#> 4 1 36 -#> 5 2 28 -#> 6 2 32 +#> # A tibble: 103 x 3 +#> from to layer +#> +#> 1 1 27 board membership +#> 2 3 27 board membership +#> 3 4 27 board membership +#> 4 5 27 board membership +#> 5 7 27 board membership +#> 6 9 27 board membership #> # i 97 more rows #> }\if{html}{\out{
}} diff --git a/man/mpn_evs.Rd b/man/mpn_evs.Rd index 1a4d772da..5e3bcd2e3 100644 --- a/man/mpn_evs.Rd +++ b/man/mpn_evs.Rd @@ -29,17 +29,17 @@ \item{Health}{1 if individual associated} } -An object of class \code{tbl_graph} (inherits from \code{igraph}) of length 672. +An object of class \code{stocnet} (inherits from \code{list}) of length 5. -An object of class \code{tbl_graph} (inherits from \code{igraph}) of length 554. +An object of class \code{stocnet} (inherits from \code{list}) of length 5. -An object of class \code{tbl_graph} (inherits from \code{igraph}) of length 1383. +An object of class \code{stocnet} (inherits from \code{list}) of length 5. -An object of class \code{tbl_graph} (inherits from \code{igraph}) of length 517. +An object of class \code{stocnet} (inherits from \code{list}) of length 5. -An object of class \code{tbl_graph} (inherits from \code{igraph}) of length 752. +An object of class \code{stocnet} (inherits from \code{list}) of length 5. -An object of class \code{tbl_graph} (inherits from \code{igraph}) of length 678. +An object of class \code{stocnet} (inherits from \code{list}) of length 5. } \source{ Knoke, David, Mario Diani, James Hollway, and Dimitris C Christopoulos. 2021. @@ -62,6 +62,11 @@ data(mpn_UK_1990) data(mpn_UK_2008) } \description{ +Superseded. These six datasets are superseded by \link{mpn_evs_ita}, \link{mpn_evs_deu}, +and \link{mpn_evs_gbr}, which hold the same data as one longitudinal network for each +country. They are kept for one release and will be removed in 1.8.0. +} +\details{ 6 two-mode matrices containing individuals' memberships to 14 different types of associations in three countries (Italy, Germany, and the UK) in 1990 and 2008. The Italy data has 658 respondents in 1990 and 540 in 2008. diff --git a/man/mpn_evs_combined.Rd b/man/mpn_evs_combined.Rd new file mode 100644 index 000000000..a42ec732b --- /dev/null +++ b/man/mpn_evs_combined.Rd @@ -0,0 +1,139 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data_mpn.R +\docType{data} +\name{mpn_evs_combined} +\alias{mpn_evs_combined} +\alias{mpn_evs_ita} +\alias{mpn_evs_deu} +\alias{mpn_evs_gbr} +\title{Longitudinal two-mode European Values Study, 1990 and 2008 (EVS 2020)} +\format{ +\if{html}{\out{
}}\preformatted{#> -- # Italy association membership network -------------------------------------- +#> # A longitudinal, labelled, two-mode network of 1198 respondents and 14 +#> associations and 2181 membership ties over 2 waves +#> +#> -- Nodes +#> # A tibble: 1,212 x 2 +#> label mode +#> +#> 1 199038000009 respondents +#> 2 199038000011 respondents +#> 3 199038000018 respondents +#> 4 199038000024 respondents +#> 5 199038000025 respondents +#> 6 199038000026 respondents +#> # i 1,206 more rows +#> +#> -- Ties +#> # A tibble: 2,181 x 3 +#> from to time +#> +#> 1 8 1199 1990 +#> 2 19 1199 1990 +#> 3 31 1199 1990 +#> 4 38 1199 1990 +#> 5 41 1199 1990 +#> 6 47 1199 1990 +#> # i 2,175 more rows +#> +}\if{html}{\out{
}} + +\if{html}{\out{
}}\preformatted{#> -- # Germany association membership network ------------------------------------ +#> # A longitudinal, labelled, two-mode network of 1872 respondents and 14 +#> associations and 3631 membership ties over 2 waves +#> +#> -- Nodes +#> # A tibble: 1,886 x 2 +#> label mode +#> +#> 1 199027600001 respondents +#> 2 199027600005 respondents +#> 3 199027600007 respondents +#> 4 199027600009 respondents +#> 5 199027600027 respondents +#> 6 199027600029 respondents +#> # i 1,880 more rows +#> +#> -- Ties +#> # A tibble: 3,631 x 3 +#> from to time +#> +#> 1 7 1873 1990 +#> 2 12 1873 1990 +#> 3 14 1873 1990 +#> 4 37 1873 1990 +#> 5 48 1873 1990 +#> 6 66 1873 1990 +#> # i 3,625 more rows +#> +}\if{html}{\out{
}} + +\if{html}{\out{
}}\preformatted{#> -- # United Kingdom association membership network ----------------------------- +#> # A longitudinal, labelled, two-mode network of 1402 respondents and 14 +#> associations and 2902 membership ties over 2 waves +#> +#> -- Nodes +#> # A tibble: 1,416 x 2 +#> label mode +#> +#> 1 199082600004 respondents +#> 2 199082600005 respondents +#> 3 199082600007 respondents +#> 4 199082600008 respondents +#> 5 199082600012 respondents +#> 6 199082600013 respondents +#> # i 1,410 more rows +#> +#> -- Ties +#> # A tibble: 2,902 x 3 +#> from to time +#> +#> 1 6 1403 1990 +#> 2 7 1403 1990 +#> 3 13 1403 1990 +#> 4 17 1403 1990 +#> 5 33 1403 1990 +#> 6 34 1403 1990 +#> # i 2,896 more rows +#> +}\if{html}{\out{
}} +} +\source{ +Knoke, David, Mario Diani, James Hollway, and Dimitris C Christopoulos. 2021. +\href{https://www.cambridge.org/core/books/multimodal-political-networks/43EE8C192A1B0DCD65B4D9B9A7842128}{\emph{Multimodal Political Networks}}. +Cambridge University Press. Cambridge University Press. +} +\usage{ +data(mpn_evs_ita) + +data(mpn_evs_deu) + +data(mpn_evs_gbr) +} +\description{ +\code{mpn_evs_ita}, \code{mpn_evs_deu}, and \code{mpn_evs_gbr} each hold one country's European Values Study +data for 1990 and 2008 in a single two-mode network. +Respondents form the first mode and the 14 types of association form the second. +The \code{time} tie attribute records the year, either 1990 or 2008. + +Italy has 1198 respondents, Germany 1872, and the United Kingdom 1402. +} +\details{ +These are repeated cross-sections, not a panel. +The European Values Study draws a new sample each round, +so no respondent appears in both years. + +Use \code{over_time()} rather than \code{over_waves()} on these objects. +\code{over_time()} restricts each year to the respondents sampled in it. +\code{over_waves()} keeps the whole node set in each wave, +which understates the density of each year. + +\if{html}{\out{
}}\preformatted{over_time(mpn_evs_ita, netrics::net_by_density, attribute = "time") +}\if{html}{\out{
}} +} +\references{ +EVS (2020). European Values Study Longitudinal Data File 1981-2008 (EVS 1981-2008). +GESIS Data Archive, Cologne. ZA4804 Data file Version 3.1.0, +\doi{10.4232/1.13486}. +} +\keyword{datasets} diff --git a/man/mpn_ryanair.Rd b/man/mpn_ryanair.Rd index 9bb170a7a..bea6ff493 100644 --- a/man/mpn_ryanair.Rd +++ b/man/mpn_ryanair.Rd @@ -6,12 +6,11 @@ \title{One-mode EU policy influence network, June 2004 (Christopoulos 2006)} \format{ \if{html}{\out{
}}\preformatted{#> -- # EU policy influence network ----------------------------------------------- -#> # A labelled, weighted, directed network of 20 policy actors and 177 -#> interaction arcs +#> # A labelled, directed network of 20 policy actors and 177 interaction arcs #> #> -- Nodes #> # A tibble: 20 x 1 -#> name +#> label #> #> 1 1 AER #> 2 2 AER @@ -22,15 +21,15 @@ #> # i 14 more rows #> #> -- Ties -#> # A tibble: 177 x 3 -#> from to weight -#> -#> 1 1 2 1 -#> 2 1 3 1 -#> 3 1 4 1 -#> 4 1 5 1 -#> 5 1 6 1 -#> 6 1 7 1 +#> # A tibble: 177 x 2 +#> from to +#> +#> 1 1 2 +#> 2 1 3 +#> 3 1 4 +#> 4 1 5 +#> 5 1 6 +#> 6 1 7 #> # i 171 more rows #> }\if{html}{\out{
}} diff --git a/man/mpn_senate.Rd b/man/mpn_senate.Rd new file mode 100644 index 000000000..907e0596b --- /dev/null +++ b/man/mpn_senate.Rd @@ -0,0 +1,82 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data_mpn.R +\docType{data} +\name{mpn_senate} +\alias{mpn_senate} +\title{Multilevel 112th Congress Senate network (Knoke et al. 2021)} +\format{ +\if{html}{\out{
}}\preformatted{#> -- # Senate contribution and voting network ------------------------------------ +#> # A labelled, undirected network of 196 senators and 5861 contribution and vote +#> ties +#> +#> -- Nodes +#> # A tibble: 196 x 3 +#> label mode community +#> +#> 1 Baucus senators both +#> 2 Begich senators A +#> 3 Bennet senators A +#> 4 Blumenthal senators A +#> 5 Boxer senators A +#> 6 BrownSh senators A +#> # i 190 more rows +#> +#> -- Missings +#> # A tibble: 2,542 x 3 +#> from to weight +#> +#> 1 52 94 NA +#> 2 53 94 NA +#> 3 54 94 NA +#> 4 55 94 NA +#> 5 56 94 NA +#> 6 57 94 NA +#> # i 2,536 more rows +#> +#> -- Ties +#> # A tibble: 5,861 x 2 +#> from to +#> +#> 1 1 94 +#> 2 2 94 +#> 3 3 94 +#> 4 4 94 +#> 5 5 94 +#> 6 6 94 +#> # i 5,855 more rows +#> +}\if{html}{\out{
}} +} +\usage{ +data(mpn_senate) +} +\description{ +\code{mpn_senate} combines the two community networks of the 112th Congress into +one multilevel network of 93 senators, 78 political action committees (PACs), +and 25 key bills. +The \code{mode} node attribute separates the three sets of nodes. + +\code{mpn_senate_dem} and \code{mpn_senate_rep} are not party networks. +The source files are named \code{Fig8.1_SxPV_CommA}, \code{Fig8.2_SxPV_CommB}, and +\code{Fig8.3_SxPV_Overlap}, so they record two communities of one network and +their intersection. +The \code{community} node attribute holds \code{"A"}, \code{"B"}, or \code{"both"}. +The 20 senators and 32 PACs and bills marked \code{"both"} reproduce \code{mpn_senate_over}. +} +\details{ +Two points of care. + +Cells that neither community covers were never observed. +They are recorded as missing rather than as absent ties, +so the object holds 2542 missing dyads. + +The two communities overlap in 640 cells and disagree in 9 of them. +Community A governs those cells: +it agrees with \code{Fig8.3_SxPV_Overlap} in all 640, where community B differs in 9. +} +\references{ +Knoke, David, Mario Diani, James Hollway, and Dimitris C Christopoulos. 2021. +\href{https://www.cambridge.org/core/books/multimodal-political-networks/43EE8C192A1B0DCD65B4D9B9A7842128}{\emph{Multimodal Political Networks}}. +Cambridge University Press. Cambridge University Press. +} +\keyword{datasets} diff --git a/man/mpn_senate112.Rd b/man/mpn_senate112.Rd index 2c44b358e..d0d4b3563 100644 --- a/man/mpn_senate112.Rd +++ b/man/mpn_senate112.Rd @@ -8,86 +8,92 @@ \alias{mpn_senate_over} \title{Two-mode 112th Congress Senate Voting (Knoke et al. 2021)} \format{ -\if{html}{\out{
}}\preformatted{#> # A labelled, weighted, two-mode network of 51 nodes and 63 nodes and 2791 ties +\if{html}{\out{
}}\preformatted{#> -- # Senate community A -------------------------------------------------------- +#> # A labelled, undirected network of 114 senators and 2791 contribution and vote +#> ties #> #> -- Nodes #> # A tibble: 114 x 2 -#> type name -#> -#> 1 FALSE Baucus -#> 2 FALSE Begich -#> 3 FALSE Bennet -#> 4 FALSE Blumenthal -#> 5 FALSE Boxer -#> 6 FALSE BrownSh +#> label mode +#> +#> 1 Baucus senators +#> 2 Begich senators +#> 3 Bennet senators +#> 4 Blumenthal senators +#> 5 Boxer senators +#> 6 BrownSh senators #> # i 108 more rows #> #> -- Ties -#> # A tibble: 2,791 x 3 -#> from to weight -#> -#> 1 1 52 1 -#> 2 1 53 1 -#> 3 1 54 1 -#> 4 1 55 1 -#> 5 1 56 1 -#> 6 1 57 1 +#> # A tibble: 2,791 x 2 +#> from to +#> +#> 1 1 52 +#> 2 1 53 +#> 3 1 54 +#> 4 1 55 +#> 5 1 56 +#> 6 1 57 #> # i 2,785 more rows #> }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{#> # A labelled, weighted, two-mode network of 62 nodes and 72 nodes and 3675 ties +\if{html}{\out{
}}\preformatted{#> -- # Senate community B -------------------------------------------------------- +#> # A labelled, undirected network of 134 senators and 3675 contribution and vote +#> ties #> #> -- Nodes #> # A tibble: 134 x 2 -#> type name -#> -#> 1 FALSE Alexander -#> 2 FALSE Ayotte -#> 3 FALSE Barrasso -#> 4 FALSE Baucus -#> 5 FALSE Blunt -#> 6 FALSE Boozman +#> label mode +#> +#> 1 Alexander senators +#> 2 Ayotte senators +#> 3 Barrasso senators +#> 4 Baucus senators +#> 5 Blunt senators +#> 6 Boozman senators #> # i 128 more rows #> #> -- Ties -#> # A tibble: 3,675 x 3 -#> from to weight -#> -#> 1 1 64 1 -#> 2 1 66 1 -#> 3 1 67 1 -#> 4 1 70 1 -#> 5 1 71 1 -#> 6 1 72 1 +#> # A tibble: 3,675 x 2 +#> from to +#> +#> 1 1 64 +#> 2 1 66 +#> 3 1 67 +#> 4 1 70 +#> 5 1 71 +#> 6 1 72 #> # i 3,669 more rows #> }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{#> # A labelled, weighted, two-mode network of 20 nodes and 32 nodes and 614 ties +\if{html}{\out{
}}\preformatted{#> -- # Senate community overlap -------------------------------------------------- +#> # A labelled, undirected network of 52 senators and 614 contribution and vote +#> ties #> #> -- Nodes #> # A tibble: 52 x 2 -#> type name -#> -#> 1 FALSE Baucus -#> 2 FALSE Cardin -#> 3 FALSE Carper -#> 4 FALSE Casey -#> 5 FALSE Collins -#> 6 FALSE Feinstein +#> label mode +#> +#> 1 Baucus senators +#> 2 Cardin senators +#> 3 Carper senators +#> 4 Casey senators +#> 5 Collins senators +#> 6 Feinstein senators #> # i 46 more rows #> #> -- Ties -#> # A tibble: 614 x 3 -#> from to weight -#> -#> 1 1 21 1 -#> 2 1 22 1 -#> 3 1 23 1 -#> 4 1 24 1 -#> 5 1 25 1 -#> 6 1 26 1 +#> # A tibble: 614 x 2 +#> from to +#> +#> 1 1 21 +#> 2 1 22 +#> 3 1 23 +#> 4 1 24 +#> 5 1 25 +#> 6 1 26 #> # i 608 more rows #> }\if{html}{\out{
}} @@ -100,6 +106,10 @@ data(mpn_senate_rep) data(mpn_senate_over) } \description{ +Superseded. These three datasets are superseded by \link{mpn_senate}, +which holds the same data as one multilevel network with a \code{community} +node attribute. They are kept for one release and will be removed in 1.8.0. + These datasets list the U.S. Senators who served in the 112th Congress, which met from January 3, 2011 to January 3, 2013. Although the Senate has 100 seats, 103 persons served during this period due diff --git a/tests/testthat/test-zzz.R b/tests/testthat/test-zzz.R new file mode 100644 index 000000000..9617999fd --- /dev/null +++ b/tests/testthat/test-zzz.R @@ -0,0 +1,66 @@ +# The attach-time check returns early when `!interactive()`, and everything else +# in R/zzz.R reaches the network, so `snet_check_versions()` is the one part a +# test can reach. It is also where the comparison happens, so it is the part +# worth covering: version 1.7.0 shipped a call to `utils::packageVersion()` on a +# version string, which stopped `library(migraph)` with +# "there is no package called '1.6.8'". + +inst <- list(migraph = "1.7.0", manynet = "2.3.1", + autograph = "1.2.2", netrics = "0.4.0") + +test_that("snet_check_versions() parses version strings rather than looking them up", { + # A version string that is not an installed package name must not error. + expect_silent( + out <- snet_check_versions(cran = c(migraph = "1.6.8"), gh = NULL, + installed = inst)) + # 1.6.8 is older than the installed 1.7.0, so nothing is reported. + expect_length(out, 0) +}) + +test_that("snet_check_versions() reports a newer version", { + out <- snet_check_versions(cran = c(migraph = "1.8.0"), gh = NULL, + installed = inst) + expect_named(out, "migraph") + expect_equal(out$migraph$version, "1.8.0") + expect_equal(out$migraph$source, "CRAN") +}) + +test_that("snet_check_versions() prefers CRAN when both are newer", { + out <- snet_check_versions(cran = c(netrics = "1.0.1"), + gh = c(netrics = "1.0.1"), installed = inst) + expect_equal(out$netrics$source, "CRAN") +}) + +test_that("snet_check_versions() falls back to GitHub when CRAN is not ahead", { + out <- snet_check_versions(cran = c(netrics = "0.4.0"), + gh = c(netrics = "1.0.1"), installed = inst) + expect_equal(out$netrics$source, "GitHub") + expect_equal(out$netrics$version, "1.0.1") +}) + +test_that("snet_check_versions() returns NULL when neither source is available", { + expect_null(snet_check_versions(cran = NULL, gh = NULL, installed = inst)) +}) + +test_that("snet_check_versions() skips a package that is not installed", { + out <- snet_check_versions(cran = c(netrics = "9.9.9"), gh = NULL, + installed = list(migraph = "1.7.0")) + expect_length(out, 0) +}) + +test_that("snet_check_versions() survives a malformed version from a repository", { + expect_silent( + out <- snet_check_versions(cran = c(migraph = "not-a-version"), gh = NULL, + installed = inst)) + expect_length(out, 0) +}) + +test_that("snet_report_outdated() names the right install command", { + expect_message( + snet_report_outdated(list(manynet = list(version = "9.9.9", source = "CRAN"))), + "update.packages", fixed = TRUE) + expect_message( + snet_report_outdated(list(manynet = list(version = "9.9.9", source = "GitHub"))), + "stocnet/manynet", fixed = TRUE) + expect_silent(snet_report_outdated(list())) +})