0
请参阅下面的代码到一个R脚本。我只是试图用商店(storeLocations)和客户(CustomerLocations)列表来填充英国地图。
STRTRADECODE是StoreLocations表中的列名,其中包含特定商店的名称。
我无法输出标签。请帮忙。
在此先感谢。
library(RgoogleMaps)
library(maps)
library(ggmap)
library(ggplot)
UKMap <- qmap("United Kingdom", zoom = 6.0)
storeOverlay <- geom_point(aes(x = longitude, y = latitude),
data = StoreLocations, colour = "red")
storeOverlay <- storeOverlay + geom_text(data= StoreLocations, aes(label=STRTRADECODE))
CustomerOverlay <- geom_point(aes(x = longitude, y = latitude),
data = CustomerLocations, colour = "green")
UKMap + CustomerOverlay + storeOverlay
尝试添加经度和纬度向geom_text元件是这样的:'geom_text(数据= StoreLocations,aes(x = longitude,y = latitude,label = STRTRADECODE))' – PhiSeu
@PhiSeu谢谢你,但仍然无法填充标签。 –
试试我的答案。在所有geom中包含'data ='属性。在一个正常的ggplot中,你定义了'ggplot(aes())'函数中的aes,并且geom继承了它们。我在这里每一步都定义它。 - 是否有某种错误信息?还是警告? – PhiSeu