Skip to content
Prev 22404 / 29559 Next

stplot - legend/classes of categorical vairable

Hi Richard, stplot as it is on CRAN does not support factor variables. I
added this support to the dev version on github, e.g. try this
(reproducible!) example:

# install spacetime from github:
devtools::install_github("edzer/spacetime")

library(spacetime)
example(STFDF)
set.seed(42)
gridded(stfdf at sp) = TRUE
stfdf$f = factor(sample(c("a", "b", "c"), 12, replace = TRUE))
library(RColorBrewer)
stplot(stfdf[,,"f"], col.regions = brewer.pal(3, "Accent"))


Make sure that your variable IS a factor, e.g. by

fdf at crop_id = as.factor(fdf at crop_id)

Your data contains many points. If they are laid out on a grid, the plot
improves if you do

gridded(fdf at sp) = TRUE

so that stplot knows, too.
On 03/04/2015 11:45 AM, richard.redweik at posteo.de wrote: