knitr::opts_chunk$set( collapse = TRUE, fig.align = "center", comment = "#>" ) knitr::opts_chunk$set( echo = TRUE)
A set of tools for unifying {sf} and {igraph} object for geospatial network analysis.
First, if you haven’t done so, install remotes
:
install.packages("remotes")
Proceed to install {migratr} from Github:
remotes::install_github("cjcallag/migratr")
The goal is to create representations of network both projected over a map or as a sociogram. Because the network is the unit of analysis, the functions are designed to work with both a edge and node list.
First, load the package and any other tools you may require (I suggest using {tidyverse} tools for data manipulation):
library(migratr) library(tidyverse)
Now load the sample node and edge lists:
edges <- migratr::edgelist nodes <- migratr::nodelist
data.frame
containing a symbolic edge list in the first two columns. Additional columns are considered as edge attributes.glimpse(edges)
data.frame
and sf
class object with node metadata. The first column will be assumed to contain the symbolic vertex names. glimpse(nodes)
Using the edge and node list produce a new object with relationships and geographic data:
migratr_object <- migratr::get_proto_graph(edges = edges[edges["edge_type"] == "Adjacency/Population",], nodes = nodes) migratr_object
Plot migratr_object
:
plot(migratr_object)
Load required data:
edges <- migratr::kurds_edgelist glimpse(edges) nodes <- migratr::kurds_nodelist glimpse(nodes)
Using the edge and node list produce a new object with relationships and geographic data:
migratr_object <- migratr::get_proto_graph(edges = edges, nodes = nodes) migratr_object
Plot migratr_object
:
plot(migratr_object)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.