[R-sig-Geo] round class intervals in legend

Marco Helbich marco.helbich at gmx.at
Tue Jul 3 11:58:24 CEST 2007


Dear list,

I've analysed my dataset with the fanny() cluster analysis function and now I want to visualise the membership values. My question is: how can I round the class interval values printed in the legend (e.g. 3 digits)? The round() function doesn't work within the classIntervals().

Below you can find an fictitious example with the sids dataset:

library(cluster)

xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
plot(xx, border="blue", axes=TRUE, las=1)
names(xx)
dat <- cbind(xx$SID74, xx$NWBIR74, xx$BIR79)
fann <- fanny(dat, 3, maxit = 1000)

par(mar=c(0.5,0.5,0.5,0.5))
plotvar <- fann$membership[,1]
nclr <- 6
plotclr <- brewer.pal(nclr, "BuPu")
class <- classIntervals(plotvar, nclr, style = "quantile")
colcode <- findColours(class, plotclr)
plot(xx)
plot(xx, col = colcode, add = T)
legend("topleft", legend=names(attr(colcode, "table")),
    fill=attr(colcode, "palette"), cex = 0.75, bty = "n")

I appreciate every hint! Thanks.

Marco
__________________

Marco Helbich
ISR
Postgasse 7/4/2
A-1010, Vienna

-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser




More information about the R-sig-Geo mailing list