[問題] ployly動圖問題

看板R_Language作者 (有咲控 = U =)時間4年前 (2020/03/21 23:32), 4年前編輯推噓5(508)
留言13則, 4人參與, 4年前最新討論串1/1
[問題類型]: 程式諮詢 [軟體熟悉度]: 使用者(已經有用R 做過不少作品) [問題敘述]: 已經有一份經緯度的資料並在地圖上表示,我想讓動圖每過一個frame,就將兩點連在一起 http://i.imgur.com/pVTkxwv.jpg
下面是我的程式 plot_ly( data = d, type = 'scattermapbox', mode = "markers+lines", lon = ~longitude, lat = ~latitude, frame = ~frame,#month text= ~text, line = list(simplyfy = F), marker = list(size = 7,color = "red"))%>% layout( mapbox = list( style = "open-street-map", center = list(lon = median(d$longitude), lat= median(d$latitude)), zoom = 2.5), margin =list(l=0,t=0,b=0,r=0)) [環境敘述]: http://i.imgur.com/Q0rqWpC.jpg
另外想問,由於我的時間格式長這樣 http://i.imgur.com/0xGWil3.jpg
目前設定frame是從1,2,3...到最後一筆 如果指定frame為datatime這個變數會有問題(因為該變數格式是字串) 所以目前是將datatime切割成以日為單位,有辦法讓他變成根據datatime的時間軸跑嗎?謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.143.8.110 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1584804751.A.D9F.html

03/21 23:34, 4年前 , 1F
最後一個問題,有辦法每過一個frame,就顯示一下該點的
03/21 23:34, 1F

03/21 23:34, 4年前 , 2F
資訊,而不用滑鼠移過去看嗎?
03/21 23:34, 2F

03/22 00:44, 4年前 , 3F
請提供測試資料…不然真的很難幫忙QQ 但我猜可以把 datetim
03/22 00:44, 3F

03/22 00:44, 4年前 , 4F
e 欄位型別(字串)改成 datetime 物件試試看
03/22 00:44, 4F
測試檔案 https://drive.google.com/file/d/1SczOXS9KrJ4o14L6L9rT-ZhmR5y8N87w/view?usp=sharing 如果出現亂碼或開不起來再跟我說 ※ 編輯: xiangying (220.143.8.110 臺灣), 03/22/2020 02:03:03

03/22 02:04, 4年前 , 5F
country是亂碼,忘記設定好,但不影響跑圖....吧
03/22 02:04, 5F

03/22 09:02, 4年前 , 6F
as.POSIXct(datetime)在R中可以轉出datetime格式
03/22 09:02, 6F

03/24 08:29, 4年前 , 7F
paste(format(data,%y-%m-%d),format(data,%H:%M:%S))
03/24 08:29, 7F

03/24 08:30, 4年前 , 8F
這樣做是因為空格讀取的問題
03/24 08:30, 8F

03/24 08:36, 4年前 , 9F
其實不用把年月日個別提出來吧,善用paste,substring,
03/24 08:36, 9F

03/24 08:36, 4年前 , 10F
format
03/24 08:36, 10F

03/24 11:16, 4年前 , 11F
謝謝樓上兩位,時間問題應該算是解決了
03/24 11:16, 11F

03/24 11:18, 4年前 , 12F
除了不知道為什麼在一開始會出現所有點之外...
03/24 11:18, 12F

03/24 11:18, 4年前 , 13F
文章代碼(AID): #1UTZEFsV (R_Language)