看板 R_Language 關於我們 聯絡資訊
[目的]-------------------------------------------- 在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
cywhale: 不太懂你的問題是連不上資料庫?錯誤訊息是dbGetQuery? 01/06 09:29
cywhale: 還是連上了?shiny掛掉?資料抓不回?還是資料像網頁show出 01/06 09:31
cywhale: 的那樣,你只是想畫出圖?但你又問整理資料?問題到底是.. 01/06 09:32
rlearner: 資料庫可以取得 ,shiny server 呈現plot也沒問題 01/11 15:19
rlearner: 只是想把資料庫中的date 和 time 欄位合拼而以 01/11 15:25
rlearner: sor~打太快,問題不清楚@@ 01/11 15:25
rlearner: 用paste合拼並用strptime轉換成t格式以乎可以解決問題 01/11 15:26