Rwww activebasic CGI
例
demo(graphics)
demo(image)
demo(persp)
demo(plotmath)
#R2.0.1,maptoolsv0.4-12 japan_jdg.shpはESRIジャパンからダウンロードして、c:/Progra~1/R/rwww/shapefiles内に入れておいてください。
library(maptools)
jpn <- read.shape("c:/Progra~1/R/rwww/shapefiles/japan_jdg.shp")
plot(jpn)
塗りわけ地図例(:http://phi.med.gunma-u.ac.jp/swtips/EpiMap.htmlより引用しました。中澤様ありがとうございました)
#R2.0.1J,maptoolsv0.4-12
library(maptools)
gunma <- read.shape("c:/Progra~1/R/rwww/shapefiles/gunma.shp")
aged <- read.delim("c:/Progra~1/R/rwww/shapefiles/agedprop.txt")
gunma$att.data <- merge(aged,gunma$att.data,sort=F,by="JCODE")
xy <- get.Pcent(gunma)
x <- xy[,1]
y <- xy[,2]
DD <- gunma$att.data$AP2003
classes <- cut(DD,seq(min(DD),max(DD),length=5),include.lowest=T) # 等間隔に区分したい場合
# classes <- cut(DD,fivenum(DD),include.lowest=T) # 階級ごとの市町村数を等しくしたい場合
table(classes)
cols <- c("azure","cyan","blue","navy")
mappoly <- Map2poly(gunma,region.id=as.character(gunma$att.data$JCODE)) #maptoolsv0.4-12ではraw=Fは不要
plot(mappoly,col=cols[ordered(classes)])
legend(min(x)-0.1*(max(x)-min(x)),min(y),legend=names(table(classes)),cex=0.4,fill=cols)
title("群馬県市町村の65歳以上高齢者割合4区分(2003年)")
text(x+0.0002,y-0.0002,as.character(gunma$att.data$CITY1),cex=0.5,pos=1,offset=0,col="white")
text(x,y,as.character(gunma$att.data$CITY1),cex=0.5,pos=1,offset=0,col="black")