geographical.neighbours: Geoggraphical neighbours graph

View source: R/variables.R

geographical.neighboursR Documentation

Geoggraphical neighbours graph

Description

How many people do you live close to within a given distance in meters

Usage

geographical.neighbours(lon, lat, id = 1:length(lon), distance = 500)

Arguments

lon

a numeric vector with longitudes

lat

a numeric vector with latitudes

id

a character vector with names

distance

maximum distance in meters

Value

a weighted graph with edge weights equal to the geographical distance

Examples

data(pe13)
graph.2km       <- geographical.neighbours(lon = pe13$lon, lat = pe13$lat, id = pe13$Name, distance = 2000)
graph.10km       <- geographical.neighbours(lon = pe13$lon, lat = pe13$lat, id = pe13$Name, distance = 10000)

graph.2km     <- graph.adjacency(afstand.2km, mode = "undirected", weighted = TRUE)
graph.10km    <- graph.adjacency(afstand.10km, mode = "undirected", weighted = TRUE)

deg.afstand.2km  <- degree(graph.2km)
deg.afstand.10km <- degree(graph.10km)

social.geography <- deg.afstand.2km
social.geography[deg.afstand.2km == 0 & deg.afstand.10km == 0] <- "Isolated at 10km"
social.geography[deg.afstand.2km == 0 & deg.afstand.10km != 0] <- "Isolated at 2km"
social.geography[deg.afstand.2km %in% 1:2]                     <- "1-2"
social.geography[deg.afstand.2km %in% 3:6]                     <- "3-6"
social.geography[deg.afstand.2km %in% 7:20]                    <- "7-20"
social.geography[deg.afstand.2km %in% 21:30]                   <- "21-30"
social.geography[deg.afstand.2km %in% 31:max(deg.afstand.2km)] <- "+30"
as.matrix(table(social.geography))

antongrau/eliter documentation built on March 2, 2024, 8:05 p.m.