README.md

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
#> PROTO_NET drugnet Nodes:293 Edges:337
#> Acquaintanceship 
#>  +-D-- E:337 N:212 NC:1
#> 
#> Edge list: 
#>  from from_class to to_class       edge_class
#>     1     person  2   person Acquaintanceship
#>     1     person 10   person Acquaintanceship
#>     2     person  1   person Acquaintanceship
#> 334 entries not printed. 
#>  + Edge attributes: 
#> 
#> Node list: 
#>  + Node attributes: name<chr> node_class<chr> Gender<chr> Ethnicity<chr> HasTie<chr> hr_ethnicity<chr> hr_gender<chr> hr_has_tie<chr>

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

COREnets::list_data_sources()
#>  [1] "anabaptists"                                 
#>  [2] "australian_embassy_bombing_2004"             
#>  [3] "bali_bombings_2002"                          
#>  [4] "bali_bombings_2005"                          
#>  [5] "christmas_eve_bombings_2000"                 
#>  [6] "ciel"                                        
#>  [7] "cocaine_smuggling_acero"                     
#>  [8] "cocaine_smuggling_jake"                      
#>  [9] "cocaine_smuggling_juanes"                    
#> [10] "cocaine_smuggling_mambo"                     
#> [11] "drugnet"                                     
#> [12] "fifa"                                        
#> [13] "harry_potter_death_eaters"                   
#> [14] "harry_potter_dumbledores_army"               
#> [15] "london_gang"                                 
#> [16] "madrid_train_bombings_2004"                  
#> [17] "montreal_street_gangs"                       
#> [18] "noordin_139"                                 
#> [19] "november17"                                  
#> [20] "paul_revere"                                 
#> [21] "siren"                                       
#> [22] "southeast_asian_aggregate_attack_series_2005"
#> [23] "vivace_bombing_cell_2005"                    
#> [24] "zegota"

Get a brief description of the data set:

COREnets::get_description("drugnet")
#> [1] "These data represent a network of drug users in Hartford.  Ties are directed and represent acquaintanceship. The network is a result of two years of ethnographic observations of people's drug habits. "

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

names(drugnet)
#> [1] "reference" "network"
class(drugnet$reference)
#> [1] "list"
class(drugnet$network)
#> [1] "list"

reference

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

Field Type Definition title character A formal title for the dataset as presented by other databases or the author. name character An informal dataset label for internal use. tags character An internal classification assinged to the dataset. description character A brief definition of the dataset to include the type of data, collection, etc. abstract character A brief summary of the data and network context. codebook data.frame A data table used for gathering and storing relationships and their definitions. bibtex character The citation for the dataset in bibtex format. Some datasets may have mupltiple entries. paper\_link character Hyperlink(s) to publications linked to the dataset.

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:

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

drugnet$network$edges_table %>%
  glimpse()
#> Observations: 337
#> Variables: 5
#> $ from       <chr> "1", "1", "2", "2", "3", "4", "4", "5", "6", "7", "7", "7"…
#> $ to         <chr> "2", "10", "1", "10", "7", "7", "211", "134", "152", "3", …
#> $ from_class <chr> "person", "person", "person", "person", "person", "person"…
#> $ to_class   <chr> "person", "person", "person", "person", "person", "person"…
#> $ edge_class <chr> "Acquaintanceship", "Acquaintanceship", "Acquaintanceship"…
drugnet$network$nodes_table %>%
  glimpse()
#> Observations: 293
#> Variables: 8
#> $ name         <chr> "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",…
#> $ node_class   <chr> "people", "people", "people", "people", "people", "peopl…
#> $ Gender       <dbl> 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,…
#> $ Ethnicity    <dbl> 1, 1, 1, 1, 3, 3, 1, 3, 1, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3,…
#> $ HasTie       <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ hr_ethnicity <chr> "White/Other", "White/Other", "White/Other", "White/Othe…
#> $ hr_gender    <chr> "Male", "Male", "Male", "Female", "Male", "Male", "Male"…
#> $ hr_has_tie   <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TR…

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)
#> IGRAPH 5c4819f DN-- 293 337 -- 
#> + attr: name (v/c), node_class (v/c), Gender (v/n), Ethnicity (v/n),
#> | HasTie (v/n), hr_ethnicity (v/c), hr_gender (v/c), hr_has_tie (v/l),
#> | from_class (e/c), to_class (e/c), edge_class (e/c)
#> + edges from 5c4819f (vertex names):
#>  [1] 1 ->2   1 ->10  2 ->1   2 ->10  3 ->7   4 ->7   4 ->211 5 ->134 6 ->152
#> [10] 7 ->3   7 ->4   7 ->9   8 ->107 8 ->117 9 ->1   9 ->2   9 ->7   10->1  
#> [19] 10->2   11->135 11->220 12->89  13->216 14->24  14->52  16->10  16->19 
#> [28] 17->64  17->79  18->55  18->104 18->165 19->18  20->64  20->182 21->16 
#> [37] 21->22  22->21  22->64  22->107 23->20  23->22  23->64  24->14  24->31 
#> [46] 24->124 27->117 28->29  29->28  30->19  31->24  31->32  31->124 31->149
#> + ... omitted several edges

core_as_network(drugnet)
#>  Network attributes:
#>   vertices = 293 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   total edges= 337 
#>     missing edges= 0 
#>     non-missing edges= 337 
#> 
#>  Vertex attribute names: 
#>     Ethnicity Gender HasTie hr_ethnicity hr_gender hr_has_tie node_class vertex.names 
#> 
#>  Edge attribute names: 
#>     edge_class from_class to_class


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