knitr::opts_chunk$set( fig.align = "center", comment = "#>", collapse = TRUE ) knitr::opts_chunk$set( echo = TRUE, message = FALSE, warning = FALSE)
First, if you haven't done so, install {remotes}:
install.packages("remotes")
Proceed to install {COREnets} from Github:
remotes::install_github("NPSCORELAB/COREnets")
{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:
metadata
: A list of lists each containing information on the different edge types contained in the edge list. The following list are included as individual nested items for each edge type sub-graph, each contain a variety of fields: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)
edges_table
: A data.frame
that contains a minimum of two columns, one column of nodes acting as a vector source or starting point (from
) and another column of nodes that are the target of the connection (to
). In addition to the from
and to
variables the data include a class variable for each (from_class
and to_class
). drugnet$network$edges_table %>% glimpse()
nodes_table
: A data.frame
contain node non-relational characteristics. A unique identifier for each node in the edge_table
should be present in the name
variable. In addition, a node_class
observation is included for each node.drugnet$network$nodes_table %>% glimpse()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.