[問題] geom_point讀值出錯
[目的]================================================
已把各點的座標資料轉為如下矩陣:
pm2.5_anime:
[,1] [,2] [,3]
[1,] "74DA3895C4C8" "74DA3895C2A6" "74DA3895C374"
[2,] "24.215748" "24.198088" "24.196424"
[3,] "120.526291" "120.523407" "120.547585"
[4,] "49.3" "57.3" "57.2"
[5,] "49.7" "56.3636363636364" "58.4"
[6,] "50.3" "58.7" "57.8"
pm2.5_anime[1,] -> 是各座標sensor的id
pm2.5_anime[2,]、pm2.5_anime[3,] ->經緯度
pm2.5_anime[4~6,] 是該座標上不同時段的pm2.5的值
希望能把pm2.5的值以geom_point顯示在
ggmap上,並用圖層疊加的方法做出動態地圖的效
但geom_point讀值時出錯QAQ
[程式]================================================
library(ggplot2)
library(ggmap)
library(mapproj)
point_f <- data.frame(lng=pm2.5_anime[3,], lat=pm2.5_anime[2,] ,
siz=pm2.5_anime[4,] )
map <- get_map(location = c(lng=120.601,lat=24.179),
zoom = 10, language = "zh-TW", maptype = "roadmap" ,scale = 1)
ggmap(map)+
geom_point(data= point_f , aes( x =lng , y=lat),size= 10)
[問題!!!]================================================
在geom_point(data= point_f , aes( x =lng , y=lat),size= 10)
這行出問題
錯誤息訊是:
Error: Discrete value supplied to continuous scale
google方法還是沒用,
求大大們幫幫忙
QAQ
還有那段錯誤倒底是什麼意思
>"<
[環境]================================================
R version 3.3.2 (2016-10-31
win7
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.128.101.15
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1487935237.A.C32.html
→
02/24 19:23, , 1F
02/24 19:23, 1F
嗯嗯~我是要畫在ggmap上
我剛有試每個值要丟入pm2.5_anime時,用as.numeric去轉,如:
pm2.5_anime <- matrix(NA,ncol= all_sensor,nrow = 9)
for(i in 1:all_sensor){#make anime matrix
pm2.5_anime[1,i] <- toString( MS_t$device_id[i+1])
pm2.5_anime[2,i] <- as.numeric(MS_t$lat[i+1])
pm2.5_anime[3,i] <- as.numeric(MS_t$lng[i+1])
}
但還是失敗
XD
※ 編輯: rleaner (140.128.101.15), 02/24/2017 19:32:17
→
02/24 20:22, , 2F
02/24 20:22, 2F
→
02/24 20:22, , 3F
02/24 20:22, 3F
→
02/24 20:22, , 4F
02/24 20:22, 4F
→
02/24 20:22, , 5F
02/24 20:22, 5F
→
02/24 20:23, , 6F
02/24 20:23, 6F
→
02/24 20:23, , 7F
02/24 20:23, 7F
嗯嗯嗯~
感謝撥冗指教
我會先回去補基礎
@@
※ 編輯: rleaner (140.128.101.15), 02/24/2017 20:43:23
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章