Description Usage Arguments Value Author(s) See Also Examples
This function implements similar features to the S4 generic stplot
from the spacetime
package for incidence
objects (from the
incidence
package), which are stratified by locations.
1 2 |
obj |
An |
sf |
A shapefile stored as a |
type |
A character string indicating the type of graphics to produce: a map ("map"), or a heatmap ("heatmap"). |
breaks |
A numeric vector indicating break points for the color scale. |
field |
A character string indicating the field containing the name of the spatial units to be used for plotting - the same as the ones used for incidence stratification. |
pal |
A color palette to be used for plotting. |
... |
Further arguments to be passed to |
The function returns a plot with extra attributes:
incience_mat
: an incidence matrix
stfdf_obj
: an stfdf object
Isobel Blake (isobel.blake@imperial.ac.uk) and Thibaut Jombart (thibautjombart@gmail.com)
getData
to fetch shapefiles freely available from GDAM
the incidence package documented at: http://www.repidemicsconsortium.org/incidence/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | ## Not run:
if (require("sp") &&
require("raster") &&
require("outbreaks") &&
require("incidence")) {
## fetch shapefiles for different admin levels
adm2data <- raster::getData('GADM', country = 'SLE', level = 2)
adm1data <- raster::getData('GADM', country = 'SLE', level = 1)
adm0data <- raster::getData('GADM', country = 'SLE', level = 0)
## plot data
plot(adm2data, border = "grey")
plot(adm1data, add = TRUE)
plot(adm0data, add = TRUE, lwd = 2)
text(sp::coordinates(adm2data), labels = adm2data$NAME_2, cex = 0.6)
## make fake data
dat <- ebola_sim$linelist
## randomly assign district location
p <- c(0.15,0.1,0.01,0.01,0.02,0,0,0.05,0.01,0,0.05,0.1,0.25,0.25)
dat$adm2 <- sample(adm2data$NAME_2, size = nrow(dat),
replace = TRUE, prob = p)
## make an incidence object
x <- incidence::incidence(dat$date_of_onset, 30, groups = dat$adm2)
## make plot
res <- spacetime(x, adm2data)
res
## extra data stored in attributes
attributes(res)
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.