ロンドンの地図上に描画したいデータがあります。
しかし、次のコードを実行しようとするたびに:
library("Hmisc")
library("lubridate")
library("maptools")
require("rworldmap")
mtl <- readShapePoly('borough/London_Borough_Excluding_MHW.shp')
data = read.csv("test.csv")
data = data[,c("Accident_Index","Longitude","Latitude","Date")]
data$Date <- as.character(data$Date)
data$Date <- gsub(' ', '', data$Date)
data$Date <- dmy(data$Date, tz='UTC')
start <- (dmy("01/01/2011", tz='UTC'))
days <- start
# pre processed matrix for incidents
# trust me you don't want to calculate
# this from scratch (Takes hours)
load('time_mat.Rdata')
# plot initial world map
plot(getMap())
da <- 1
# where the plots will be outputted
png(paste('plots/',days[da],'.png',sep=''), height=800, width=1200, bg='grey')
# plot london map
plot(mtl,col='darkgrey')
text(51.5072, 0.1275,paste("Collisions in London\n",days[da]),cex=2)
points(data$Longitude,data$Latitude, pch=20, col='white', cex=2)
par(lwd=2.5,cex=1.4)
subplot(
plot(days[1:da],incident_rate[1:da],
lwd=1.5,type='l',
ylab='', xlab='',
col='red',
ylim=c(0,max(c(1,max(incident_rate[1:da]))))
),
size=c(5.5,2), 51.5072, -0.1275, vadj=0,hadj=0
)
dev.off()
par(plt = c(xy$x, xy$y), new = TRUE) のエラー: グラフィカル パラメータ "plt" に指定された無効な値
EDIT 2:コードをリファクタリングして削減しました。
コード フォルダー全体を zip 圧縮し、展開/テストを容易にするために依存データを 17 MB まで圧縮しました (シェープファイルのため)。