The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
Interspecific data can be used with {spatsoc} to estimate interspecific interactions, eg. predator-prey dynamics.
See the other vignettes for further information:
group_pts,
group_lines, group_polysedge_distgroup_times,
group_pts, group_lines,
group_polys, edge_dist, edge_nn,
and randomizationsedge_dist and
edge_nndyad_idfusion_idget_geometry to setup a geometry column and use
the geometry interfaceGiven two movement datasets, simply bind them together and use the
group_* functions as usual.
# Load packages
library(spatsoc)
library(data.table)
# Load data
predator <- fread(system.file("extdata", "DT_predator.csv", package = "spatsoc"))
prey <- fread(system.file("extdata", "DT_prey.csv", package = "spatsoc"))
# Combine data
DT <- rbindlist(list(predator, prey))
# Set the datetime as a POSIxct
DT[, datetime := as.POSIXct(datetime)]
# Temporal grouping
group_times(DT, datetime = 'datetime', threshold = '10 minutes')
#> ID X Y datetime population type minutes
#> <char> <num> <num> <POSc> <int> <char> <int>
#> 1: B 708315.6 5460839 2016-11-30 14:00:45 1 predator 0
#> 2: A 709764.2 5458231 2017-01-05 10:00:54 1 predator 0
#> 3: B 709472.3 5460132 2016-12-03 08:00:42 1 predator 0
#> 4: A 713630.5 5456393 2017-01-27 02:01:16 1 predator 0
#> 5: B 707303.2 5461003 2016-12-17 18:00:54 1 predator 0
#> ---
#> 5824: G 708660.2 5459275 2017-02-28 14:00:44 1 prey 0
#> 5825: G 708669.4 5459276 2017-02-28 16:00:42 1 prey 0
#> 5826: G 708212.0 5458998 2017-02-28 18:00:53 1 prey 0
#> 5827: G 708153.2 5458953 2017-02-28 20:00:12 1 prey 0
#> 5828: G 708307.6 5459182 2017-02-28 22:00:46 1 prey 0
#> timegroup
#> <int>
#> 1: 1
#> 2: 2
#> 3: 3
#> 4: 4
#> 5: 5
#> ---
#> 5824: 1422
#> 5825: 1423
#> 5826: 1424
#> 5827: 1425
#> 5828: 1440
# Spatial grouping
group_pts(DT, threshold = 50, id = 'ID',
coords = c('X', 'Y'), timegroup = 'timegroup')
#> ID X Y datetime population type minutes
#> <char> <num> <num> <POSc> <int> <char> <int>
#> 1: B 708315.6 5460839 2016-11-30 14:00:45 1 predator 0
#> 2: A 709764.2 5458231 2017-01-05 10:00:54 1 predator 0
#> 3: B 709472.3 5460132 2016-12-03 08:00:42 1 predator 0
#> 4: A 713630.5 5456393 2017-01-27 02:01:16 1 predator 0
#> 5: B 707303.2 5461003 2016-12-17 18:00:54 1 predator 0
#> ---
#> 5824: G 708660.2 5459275 2017-02-28 14:00:44 1 prey 0
#> 5825: G 708669.4 5459276 2017-02-28 16:00:42 1 prey 0
#> 5826: G 708212.0 5458998 2017-02-28 18:00:53 1 prey 0
#> 5827: G 708153.2 5458953 2017-02-28 20:00:12 1 prey 0
#> 5828: G 708307.6 5459182 2017-02-28 22:00:46 1 prey 0
#> timegroup group
#> <int> <int>
#> 1: 1 1
#> 2: 2 2
#> 3: 3 3
#> 4: 4 4
#> 5: 5 5
#> ---
#> 5824: 1422 5467
#> 5825: 1423 5468
#> 5826: 1424 5469
#> 5827: 1425 5470
#> 5828: 1440 5471
# Calculate the number of types within each group
DT[, n_type := uniqueN(type), by = group]
DT[, interact := n_type > 1]
# Prey's perspective
sub_prey <- DT[type == 'prey']
sub_prey[, mean(interact)]
#> [1] 0.01169693
# Plot --------------------------------------------------------------------
# If we subset only where there are interactions
sub_interact <- DT[(interact)]
plot(sub_prey$X, sub_prey$Y, col = 'grey', pch = 21)
points(sub_interact$X, sub_interact$Y, col = factor(sub_interact$type))These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.