For each event, the mean centre of the span events centred on it in
time order (ties in input order), the window shortened at the ends of
the series. It traces how the centre of a series of incidents moves
over time. It is a descriptive device of the crime-mapping literature
with no original paper to cite; the mean centre is that of cgstat().
Arguments
- x, y
The points:
xandynumeric vectors of equal length; orxa matrix or data frame with columns namedxandy(orXandY, assf::st_coordinates()names them, orlonandlatwithlonlat = TRUE) andyNULL; orxan sf or sfc object of POINT geometries, whose coordinate reference system must agree withlonlat. An unnamed two-column matrix is read asxtheny; other columns are never taken by position. Vectors given separately (x,y, andwortwhere a function takes them) are matched by name when every one is named and no name repeats, as elsewhere in the package; otherwise by position. No missing or infinite values.- t
The time of each event: finite numbers (for dates,
as.numeric()of them, in days or seconds).- span
The window: one odd whole number from 1.
- lonlat
FALSE(the default) whenxandyare planar coordinates in one length unit;TRUEwhen they are longitude and latitude in degrees, which are then projected to metres byeqproj()about their own centre, and centres are returned in degrees. It is never guessed.
Value
A data frame with one row per event, in input order: mx, my
(the window's mean centre, in degrees when lonlat = TRUE) and n
(events in the window).
Examples
stmavg(x = 1:7, y = c(1, 1, 2, 3, 5, 8, 13), t = 7:1, span = 3)
#> mx my n
#> 1 1.5 1.000000 2
#> 2 2.0 1.333333 3
#> 3 3.0 2.000000 3
#> 4 4.0 3.333333 3
#> 5 5.0 5.333333 3
#> 6 6.0 8.666667 3
#> 7 6.5 10.500000 2