看板 R_Language 關於我們 聯絡資訊
[問題類型]: 程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來) [軟體熟悉度]: 入門(寫過其他程式,只是對語法不熟悉) [問題敘述]: 正在摸索用SHINY來寫網頁,請問如何不靠手寫輸入formula? 例如像這樣一個函式 glm1 <- glm(Tr ~ age + educ + black + hisp + married + nodegr + + re74 + re75, family = binomial, data = lalonde) 變數是從CSV檔讀取的Header,不是固定的變數名稱。 另外也在考慮也許從網頁輸入EVAL? 在EVAL欄位產生default值, 這樣可以手動設定方程式的係數.. [關鍵字]: shiny, formula -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.137.56 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1421750525.A.4ED.html
Wush978: ?reformulate 01/20 18:55
Wush978: ?as.formula 01/20 18:55
Wush978: 以上是我知道的兩個關鍵字,希望有幫助 01/20 18:55
EricTao: 感謝,剛剛有在看as.formula但是不太確定 01/20 19:52
celestialgod: 我理解是類似這樣的東西... as. formula(paste(resp 01/21 12:36
celestialgod: onseName, paste(names(dataname[names(datname! =r 01/21 12:36
celestialgod: esponseName)]), sep='+'), sep='~' ) 01/21 12:36
celestialgod: 更正成names(dataname)[names(datname)! =responseN 01/21 12:37
celestialgod: ame]這樣才對 01/21 12:37
Wush978: reformulate(colnames(data_frame_obj)) 01/21 13:29
celestialgod: reformulate原來這樣用 學了一招!! 01/22 10:28
Wush978: 還有 ~ . 也可以all in 01/22 18:11
EricTao: 感謝~用reformulate達成 能直接用dataFrame太棒了0.0 01/27 16:49
EricTao: 不過我第一個column是ID,研究下怎麼把它拿掉 01/27 16:50
Wush978: tail(x, -1) 可以拿掉x 的第一個element 01/28 21:17
感謝,最後還是寫個介面來選擇變數。 output$chooser<-renderUI({ checkboxGroupInput("cocho","choose covas",colnames(cova),selected=tail(colnames(cova),-1)) }) output$formula<-renderText({ as.character(reformulate(input$cocho,input$tr)) }) 長這樣 http://ppt.cc/wauk ※ 編輯: EricTao (140.112.137.56), 02/02/2015 00:24:35