- This topic has 1 reply, 2 voices, and was last updated 3 years, 3 months ago by .
Viewing 1 reply thread
Viewing 1 reply thread
You must be logged in to reply to this topic. Login here
Home › Forums › TMHG 517 Statistical methods in spatial epidemiology 2020 › Course Forums › How does spplot really work?
E.cutoff <- c(70, 100, 120, 140, 180)
cat.E <- cut(
unlist(data.suicides$E),
breaks=E.cutoff,
include.lowest=TRUE
)
maps.cat.E <- data.frame(ID=data.suicides$ID, cat.E=cat.E)
attr(london.gen, "data") <- merge(
attr(london.gen, "data"),
maps.cat.E,
by="ID"
)
spplot(
obj=london.gen,
zcol="cat.E",
main=list(label="Expected case", cex=1),
col.regions=gray(seq(0.9, 0.1, length=4))
)
As I can see, attr(london.gen, "data")
is updated prior to running spplot
, but why?
You may need to attribute london.gen to the data.boroughs before merge, as command below.
E.cutoff <- c(70, 100, 120, 140, 180)
cat.E <- cut(unlist(data.suicides$E), breaks = E.cutoff, include.lowest = T)
maps.cat.E <- data.frame(ID=data.suicides$ID, cat.E=cat.E)
data.boroughs <- attr(london.gen, “data”)
attr(london.gen, “data”) <- merge(data.boroughs, maps.cat.E, by=”ID”)
spplot(obj = london.gen, zcol = “cat.E”, main=list(label=”Expected case”, cex=1), col.regions=gray(seq(0.9,0.1,length=4)))
Hope it can solve your problem.
You must be logged in to reply to this topic. Login here