Re: [問題] 在shiny上以rCharts畫scatter plot

看板R_Language作者 (攸藍)時間10年前 (2015/07/26 15:13), 10年前編輯推噓3(306)
留言9則, 1人參與, 最新討論串2/2 (看更多)
7/26 16:23更新: 後來測試成功,重點在於設定dom的名稱 code: http://pastebin.com/6c0gdc1Y nPlot成功案例:http://tinyurl.com/ovuxmpt 7/26 15:10寫的: 我跑是沒出現任何警告跟錯誤,我的環境列於下方: 而且有正常呈現,不過你的scatter_plot那個tab沒有圖就是 > sessionInfo() R version 3.2.0 (2015-04-16) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 locale: [1] LC_COLLATE=Chinese (Traditional)_Taiwan.950 [2] LC_CTYPE=Chinese (Traditional)_Taiwan.950 [3] LC_MONETARY=Chinese (Traditional)_Taiwan.950 [4] LC_NUMERIC=C [5] LC_TIME=Chinese (Traditional)_Taiwan.950 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] shiny_0.11.1 rCharts_0.4.5 loaded via a namespace (and not attached): [1] R6_2.0.1 plyr_1.8.2 htmltools_0.2.6 tools_3.2.0 [5] whisker_0.3-2 yaml_2.1.13 Rcpp_0.11.5 RJSONIO_1.3-0 [9] grid_3.2.0 digest_0.6.8 xtable_1.7-4 httpuv_1.3.2 [13] mime_0.3 lattice_0.20-31 測試code: http://pastebin.com/qxpRSm0y (我只是把ui.R跟server.R合併到function而已) ※ 引述《ardodo (米蟲)》之銘言: : [問題類型]: : : 程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來) : : [軟體熟悉度]: : 請把以下不需要的部份刪除 : 入門(寫過其他程式,只是對語法不熟悉) : : [問題敘述]: : 版友好,我試著以rCharts在shiny上繪製iris的散布圖,但是畫不出來,不知道為什麼 : code在此 http://pastebin.com/EkS2YxcC : 執行shiny後,會跳出以下的訊息: : Note: the specification for S3 class “AsIs” in package ‘jsonlite’ seems : equivalent to one from package ‘RJSONIO’: not turning on duplicate class : definitions for this class. : 懇請解答,感謝 : 附上我的sessionInfo : other attached packages: : [1] rCharts_0.4.5 shiny_0.12.1 : loaded via a namespace (and not attached): : [1] Rcpp_0.11.6 lattice_0.20-31 digest_0.6.8 mime_0.3 : grid_3.2.1 : [6] R6_2.1.0 plyr_1.8.3 xtable_1.7-4 jsonlite_0.9.16 : rstudioapi_0.3.1 : [11] whisker_0.3-2 RJSONIO_1.3-0 tools_3.2.1 httpuv_1.3.2 : yaml_2.1.13 : [16] rsconnect_0.4.1.2 htmltools_0.2.6 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.205.27.107 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1437894791.A.4C4.html

07/27 11:44, , 1F
感謝版主的回文,看起來rCharts的不同套件功能如hPlot,
07/27 11:44, 1F

07/27 11:45, , 2F
rPlot, nPlot在設定上略有不同,而重點就是dom要指名
07/27 11:45, 2F

07/27 11:45, , 3F
不曉得哪裡有rCharts底下各種圖的用法說明文件?
07/27 11:45, 3F

07/27 11:46, , 4F
我找了好久只找到rCharts Documentation比較完整
07/27 11:46, 4F

07/27 11:47, , 5F
想知道如何設定圖形大小、margin等圖形參數
07/27 11:47, 5F
我也仔細去查過了,rCharts只有examples 你要修正rCharts,只能去看他們只使用的library,然後去做修改 你在rCharts的github可以看到相關的敘述 rCharts supports multiple javascript charting libraries, each with its own strengths. Each of these libraries has multiple customization options, most of which are supported within rCharts. More documentation is underway on how to use rCharts with each of these libraries. 所以細部設定的文件都還在寫,不過你那些js library的選項大都有支援 因此,你可以嘗試去查那些js library做參數修改

07/27 12:04, , 6F
原來如此,所以就是要查看看這些rCharts支援的js library
07/27 12:04, 6F

07/27 12:04, , 7F
是怎麼設定圖形的囉?感謝回答
07/27 12:04, 7F
舉例來說,我要改chart一些參數,你可以從nvd3找到 透過chart這個函數你可以去設定他的參數(這部分我直接去翻source code) library(rCharts) h = 600 w = 600 padding = 40 n1 = nPlot(Sepal.Length ~ Sepal.Width, data = iris, group = "Species", type = "scatterChart") xlim = range(iris$Sepal.Width) xlim = xlim * c(0.95, 1.05) + diff(xlim) * c(-0.1, 0.1) ylim = range(iris$Sepal.Length) ylim = ylim * c(0.95, 1.05) + diff(ylim) * c(-0.1, 0.1) n1$chart(xRange = c(0, w - padding), yRange = c(h-padding*2, padding), xDomain = xlim, yDomain = ylim) n1$addParams(height = h, width = w) n1 這裡xRange, xDomain這些都來自d3.js的 d3.scale.range跟 d3.scale.domain 如果沒有這個相關知識,你可能很難去做這方面的調整 這個已經超出R版範圍,我幫助也有限 而且我也只是之前稍微研究過d3.js,我沒辦法提供太多資訊

07/27 13:44, , 8F
感謝版主熱心的分享,看來這需要學習js才能解決
07/27 13:44, 8F

07/27 13:44, , 9F
太感謝了!!!!
07/27 13:44, 9F
你只能期待rCharts作者可以把文件寫得更加詳細 讓R使用者不必知道js也可以做 ※ 編輯: celestialgod (123.205.27.107), 07/27/2015 13:49:28
文章代碼(AID): #1Lj8Y7J4 (R_Language)
討論串 (同標題文章)
文章代碼(AID): #1Lj8Y7J4 (R_Language)