Description Usage Arguments Value Examples
Number of neighbors adjacent to each actor. Calculated excluding self from set of neighbors.
1 | layer_neighbors(DT, id, splitBy = NULL)
|
DT |
a data.table with column "group" generated by spatsoc::group_pts |
id |
|
splitBy |
the column which defines the layers of the network |
The input DT with additional column "neigh" and optionally "splitNeigh" if a column was provided for the 'splitBy' argument.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # Load data.table and spatsoc
library(data.table)
library(spatsoc)
# Read example data
DT <- fread(system.file("extdata", "DT.csv", package = "spatsoc"))
# Cast the character column to POSIXct
DT[, datetime := as.POSIXct(datetime, tz = 'UTC')]
# Temporal grouping
group_times(DT, datetime = 'datetime', threshold = '20 minutes')
# Spatial grouping with timegroup
group_pts(DT, threshold = 5, id = 'ID',
coords = c('X', 'Y'), timegroup = 'timegroup')
# Pseudo-season
DT[, season := sample(c(1, 2), .N, replace = TRUE)]
layer_neighbors(DT, 'ID', splitBy = 'season')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.