[R] paired raster boxplots

Ivan Krylov |kry|ov @end|ng |rom d|@root@org
Thu Aug 22 16:49:31 CEST 2024


В Thu, 22 Aug 2024 08:46:03 +0200
SIBYLLE STÖCKLI via R-help <r-help using r-project.org> пишет:

> rr2s <- stack(r, r2,s)

> > names(rs) <- c('r', 's', 'r2')  
> 
> Error in `names<-`(`*tmp*`, value = c("r", "s", "r2")) :
> 
>   incorrect number of layer names

The error must be happening because the variable named 'rs' in your
workspace originates from some other code you have previously run. The
code "works" if you replace names(rs) by names(rr2s), but the plot isn't
very useful because d$s are real numbers in this example and they don't
form groups for d$r.

Are you interested in a boxplot where the boxes are grouped by two, one
for 'r' and one for 'r2'? I'm sure they are not impossible to produce
manually using the boxplot function, but the 'lattice' or 'ggplot2'
packages would make them much easier. You will need to reshape your
data into long format, with the "value" column for the r/r2 value, the
"kind" column saying "r" or "r2", and the "s" column:
https://stackoverflow.com/q/20172560

-- 
Best regards,
Ivan



More information about the R-help mailing list