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