riatelab / flows

Flow selection and analysis
11 stars 2 forks source link
cran flows r r-package

flows: Selections on flow matrices, statistics on selected flows, cartographic and graphic visualizations

Version R-CMD-check

The analysis and representation of flows often presuppose a selection to facilitate interpretation. Various methods have been proposed for selecting flows, one of the most widely used being based on major flows: it selects only the most important flows, absolute or relative, on a local or global scale. These methods often highlight hierarchies between locations, but the loss of information caused by selection is rarely taken into account. It therefore seems useful to propose statistical indicators to assess the loss of information and the characteristics of selected flows. We provide functions that select flows (main, dominant or major flows), provide statistics on selections and offer visualizations in the form of maps and graphs.

Installation

You can install the development version of flows from GitHub with:

remotes::install_github("riatelab/flows")

Usage

Example of a dominant flows analysis on commuters data:

library(sf)
library(flows)
library(mapsf)
# Import datasets
nav <- read.csv(system.file("csv/nav.csv", package = "flows"))
# Trnasform to wide
mat <- prepare_mat(x = nav, i = "i", j = "j", fij = "fij")
# import spatial objects
UA <- st_read(system.file("gpkg/GE.gpkg", package = "flows"), 
              layer = "urban_area", quiet = TRUE)
GE <- st_read(system.file("gpkg/GE.gpkg", package = "flows"), 
              layer = "region", quiet = TRUE)
# Map
mf_map(GE, col = "#c6deba")
out <- map_nodal_flows(mat = mat, x = UA,
                       inches = .17,
                       col_node = c('red', 'orange', 'yellow'),
                       col_flow = "grey30",
                       breaks = c(4,100,1000,2500,8655),
                       lwd = c(1,4,8,16), add = TRUE)
mf_label(out$nodes[out$nodes$w>6000,], var = 'name',
         halo = TRUE, overlap = FALSE, pos = 4)
mf_title("Dominant Flows of Commuters")
mf_credits("INSEE, 2011")
mf_scale(50)

Ressources

Community Guidelines

One can contribute to the package through pull requests and report issues or ask questions here.