[問題] plot出date-time資料整理

看板R_Language作者 (rlearner)時間8年前 (2017/01/04 01:34), 編輯推噓0(007)
留言7則, 2人參與, 最新討論串1/2 (看更多)
[目的]-------------------------------------------- 在ubuntu 環境上取用Mysql資料 並使用shiny server 去plot呈現折線圖 (之所以會用plot是因為shiny server無法library(ggplot2)) [問題]-------------------------------------------- 我從mysql取得的資料 如下url: http://140.128.197.58:3838/sample-apps/rmysql2/ 的下面的表格 plot-xy圖中 x軸是time y軸是PM2.5 該資料有兩個欄位都是時間 不知可否吧 Date和time 合拼 或不用合拼,只要讓x是照時間順序plot出pm2.5就行 [code]-------------------------------------------- 以下是在server.R的code,用shiny 執行 library(DBI) library(RMySQL) conn <- dbConnect(MySQL(), host="localhost", dbname="Airbox", username = "root", password = "[password]") #成功連上數據庫 ES = dbGetQuery(conn, "select * from data_school where site='ES'") plot(ES$time, ES$PM2.5, type="l") [錯訊訊息]-------------------------------------------- (chrom訊息) Error:An error has occurred. Check your logs or contact the app suthor for clarification. (按F12 Console) Wed Jan 04 2017 01:31:16 GMT+0800 (台北標準時間) [DBG]: 3 message(s) discarded from buffer 希望大神,有什麼方法可整理資料?? @@ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.128.101.143 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1483464878.A.63F.html

01/06 09:29, , 1F
不太懂你的問題是連不上資料庫?錯誤訊息是dbGetQuery?
01/06 09:29, 1F

01/06 09:31, , 2F
還是連上了?shiny掛掉?資料抓不回?還是資料像網頁show出
01/06 09:31, 2F

01/06 09:32, , 3F
的那樣,你只是想畫出圖?但你又問整理資料?問題到底是..
01/06 09:32, 3F

01/11 15:19, , 4F
資料庫可以取得 ,shiny server 呈現plot也沒問題
01/11 15:19, 4F

01/11 15:25, , 5F
只是想把資料庫中的date 和 time 欄位合拼而以
01/11 15:25, 5F

01/11 15:25, , 6F
sor~打太快,問題不清楚@@
01/11 15:25, 6F

01/11 15:26, , 7F
用paste合拼並用strptime轉換成t格式以乎可以解決問題
01/11 15:26, 7F
文章代碼(AID): #1OQ-2kO_ (R_Language)
討論串 (同標題文章)
文章代碼(AID): #1OQ-2kO_ (R_Language)