[問題] RShiny Ui Server對應

看板R_Language作者 (林翰)時間6年前 (2018/11/13 05:37), 編輯推噓1(107)
留言8則, 2人參與, 6年前最新討論串1/1
[問題類型]: 程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來) [軟體熟悉度]: 使用者(已經有用R 做過不少作品) [問題敘述]: 最近在使用RShiny做圖表 想問有經驗的大大如何讓這兩個Ui 跟 Server連結起來 我是想做grouped bar plot 但一直無法將server的y [程式範例]: 程式碼可貼於以下網站: UI: sidebarPanel( selectInput("var", "Select the variable from this dataset", choices = c("English score" = mod_data$eperpospts, "math score" = mod_data$mperpospts)), s我定義一個input名叫var 然後我想要讓我的English score跟 math score是可以被選擇的 Server: ggplot(mod_data, aes(y=eperpospts, x = race, fill = highneeds)) + stat_summary(fun.y = mean, geom = "bar", position = "dodge") 然後在y的部分一直無法跟Ui連結 想不到辦法 不知道大大們有什麼建議 非常感謝 如果能幫忙的大大 我以200P作為答謝 [關鍵字]: RShiny -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 65.96.232.71 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1542058643.A.41B.html

11/13 07:43, 6年前 , 1F
你server端的ggplot要用到input$var來控制你的y
11/13 07:43, 1F

11/13 07:43, 6年前 , 2F

11/13 07:45, 6年前 , 3F
你可以看一下UI的input 在server端如何被使用
11/13 07:45, 3F

11/13 08:06, 6年前 , 4F
如果你的mod_data只在server端,你的UI(client端)要用它
11/13 08:06, 4F

11/13 08:08, 6年前 , 5F
要用uiOuptut 請看Rstudio shiny Dynamic UI相關內容介紹
11/13 08:08, 5F

11/13 08:08, 6年前 , 6F
https://goo.gl/mYLtxp 簡單說 ui.R放uiOutput()就好
11/13 08:08, 6F

11/13 08:09, 6年前 , 7F
在server端才明確把selectInput指定給這個uiOutput 然後
11/13 08:09, 7F

11/13 08:10, 6年前 , 8F
choices就可以使用server端的變數比如你要的mod_data$...
11/13 08:10, 8F
文章代碼(AID): #1RwVAJGR (R_Language)
文章代碼(AID): #1RwVAJGR (R_Language)