animate_grid: Visualizing the spatio-temporal pattern of an outbreak’s...

View source: R/animate_grid.R

animate_gridR Documentation

Visualizing the spatio-temporal pattern of an outbreak’s transmision potential

Description

Generate animation of the spatial pattern of cases by grid; aggregate the point into specified grids

Usage

animate_grid(
  x,
  y,
  t,
  Rj = NULL,
  hex = FALSE,
  grid.n = 50,
  crs = NULL,
  bnd = NULL,
  basemap = NULL,
  interval = c("day", "week", "month"),
  gridLonLat = TRUE,
  width = 600,
  height = 400,
  delay = 50,
  title = "",
  n.breaks = 6
)

Arguments

x

Vector of x coordinates of data points.

y

Vector of y coordinates of data points.

t

Vector of time of data points.

Rj

Vector of individual reproductive numbers of data points.

hex

Logical; if'TRUE', create hexagonal grid ; if'FALSE', create square grid.

grid.n

Number of grid cells in one direction (shorter side).

crs

Coordinate reference system of data points: numeric (EPSG code), object of class 'crs', or input string for st_crs; if NULL, using CRS of basemap, or using WGS84 (EPSG:4326).

bnd

A 4-length numerical vector of the form c(xmin, ymin, xmax, ymax) which gives the number of x and y coordinates' ranges of the map.

basemap

Object of class 'sf'; basemap plotting on map.

interval

Character; time resolution(day, week, month) of animation ; aggregrate data through day, week or month.

gridLonLat

Logical; draw latitude and longitude grid on non-interactive map.

width

Width of the animation file (in pixels).

height

Height of the animation file (in pixels).

delay

Delay time between images (in 1/100th of a second).

title

Main title of animation.

n.breaks

Number of classify classes.

Examples

data("EpiTrans")

res_adj = Rj(t = dengue$date, x = dengue$long, y = dengue$lat,GI.pdf = lpdf_GI(),SW.pdf = lpdf_SW(), adjSP = TRUE)
dengue$Rj = res_adj$Rj
dengue = dengue[dengue$date > as.Date("2007-09-15") & dengue$date < as.Date("2007-10-15"),]


animate_grid(x=dengue$long, y=dengue$lat, t=dengue$date, Rj = dengue$Rj, grid.n=20, hex = TRUE, basemap = Taiwan, interval="week")

wenlab501/EpiTrans documentation built on July 8, 2022, 9:14 a.m.