我期待在从哈德利韦翰的下面的例子ggplot2
:
library(ggplot2)
library(maps)
states<-map_data("state")
arrests<-USArrests
names(arrests)<-tolower(names(arrests))
arrests$region<-tolower(rownames(USArrests))
chloro<-merge(states, arrests, by="region")
chloro<-chloro[order(chloro$order), ]
qplot(long, lat, data=chloro, group=group, fill = assault, geom="polygon")
那么我想补充点一些显着的美国城市地图,但我一直没能来。 我试过了:
base_map<-qplot(long, lat, data=chloro, group=group, fill = assault, geom="polygon")
base_map + qplot(long, lat, data=us.cities) + borders("state", size=.5)
但我得到以下错误:
Error in p + o : non-numeric argument to binary operator
In addition: Warning message:
Incompatible methods ("+.ggplot", "Ops.data.frame") for "+""
如何添加这些点?