knitr::opts_chunk$set(
  fig.align = "center",
  comment   = "#>",
  collapse  = TRUE
)

knitr::opts_chunk$set(
  echo    = TRUE,
  message = FALSE,
  warning = FALSE)

COREnets

Lifecycle GitHub last commit Codecov test coverage AppVeyor build status Travis-CI Build Status License: GPL v3 Depends GitHub code size in bytes HitCount

Installation

First, if you haven't done so, install {remotes}:

install.packages("remotes")

Proceed to install {COREnets} from Github:

remotes::install_github("NPSCORELAB/COREnets")

Using the Package to Access Data

{COREnets} contains a series of network data sets that can be accessed using the get_data function:

library(COREnets)
drugnet <- COREnets::get_data("drugnet")
drugnet

In order to look up the available data sets use the list_data_sources function:

COREnets::list_data_sources()

Get a brief description of the data set:

COREnets::get_description("drugnet")

Each data object contains two main lists of information, the reference and network lists:

names(drugnet)
class(drugnet$reference)
class(drugnet$network)

reference

The reference list contains the following fields of information on the data set:

library(tidyverse)

metadata <- tibble::tibble(
  Field = c(
    "title",
    "name",
    "tags",
    "description",
    "abstract",
    "codebook",
    "bibtex",
    "paper_link"
  ),
  Type = c(
    "character",
    "character",
    "character",
    "character",
    "character",
    "data.frame",
    "character",
    "character"
  ),
  Definition = c(
    "A formal title for the dataset as presented by other databases or the author.",
    "An informal dataset label for internal use.",
    "An internal classification assinged to the dataset.",
    "A brief definition of the dataset to include the type of data, collection, etc.",
    "A brief summary of the data and network context.",
    "A data table used for gathering and storing relationships and their definitions.",
    "The citation for the dataset in bibtex format. Some datasets may have mupltiple entries.",
    "Hyperlink(s) to publications linked to the dataset."
  )
)
metadata %>%
  knitr::kable(format = "html", escape = TRUE) %>%
  kableExtra::kable_styling(bootstrap_options = c("bordered"))

network

The network list contains all the relevant data to generate a sociogram and conduct the analysis. However, because each data set is slightly different, this list is segmented into three entries:

net_metadata <- data.frame(
  Field = c(
    "edge_class",
    "is_bimodal",
    "is_directed",
    "is_dynamic",
    "is_weighted",
    "has_isolates",
    "has_loops",
    "edge_count",
    "node_count",
    "node_classes"
  ),
  Type = c(
    "character",
    "logical",
    "logical",
    "logical",
    "logical",
    "logical",
    "logical",
    "double",
    "double",
    "double"
  ),
  Definition = c(
    "A string matching the name of an edge class in the codebook.", 
    "A logial denoting wheter or not the edge type yields a bipartite graph.",
    "A logical denoting whether the network edges are directed or not.",
    "A logical denoting whether the edges are dynamic or not.",
    "A logical denoting whether or not the edges are weighted.",
    "A logical which defines if the graph contains isolates or not.",
    "A logical defining the presence or absence of self-loops.",
    "A number corresponding to the number of edges.",
    "A number corresponding to the number of nodes.",
    "A number corresponding to the number of node classes included for each edge class."
  )
)

net_metadata %>%
  knitr::kable(format = "markdown",
               escape = TRUE,
               row.names = FALSE)
drugnet$network$edges_table %>%
  glimpse()
drugnet$network$nodes_table %>%
  glimpse()

Generating Graph Objects

Each network in the package contains the necessary edges and nodes tables to generate network objects with {igraph} or {network}. For instance:

core_as_igraph(drugnet)

core_as_network(drugnet)


NPSCORELAB/COREnets documentation built on March 28, 2020, 7:57 a.m.