4
我有以下代碼。有什麼方法可以像lapply那樣在循環語句或矢量化語句中編寫它?在我的真實代碼中,我有更多的畫筆,所以這將非常有幫助。謝謝。R Shiny:如何爲observeEvent編寫循環
忽略此行。只需要添加更多的文本。
observeEvent(input$brush_1,{
Res=brushedPoints(D(),input$brush_1,allRows = TRUE)
vals$keeprows = Res$selected_
})
observeEvent(input$brush_2,{
Res=brushedPoints(D(),input$brush_2,allRows = TRUE)
vals$keeprows = Res$selected_
})
observeEvent(input$brush_3,{
Res=brushedPoints(D(),input$brush_3,allRows = TRUE)
vals$keeprows = Res$selected_
})
observeEvent(input$brush_4,{
Res=brushedPoints(D(),input$brush_4,allRows = TRUE)
vals$keeprows = Res$selected_
})
observeEvent(input$brush_5,{
Res=brushedPoints(D(),input$brush_5,allRows = TRUE)
vals$keeprows = Res$selected_
})
observeEvent(input$brush_6,{
Res=brushedPoints(D(),input$brush_6,allRows = TRUE)
vals$keeprows = Res$selected_
})
observeEvent(input$brush_7,{
Res=brushedPoints(D(),input$brush_7,allRows = TRUE)
vals$keeprows = Res$selected_
})
observeEvent(input$brush_8,{
Res=brushedPoints(D(),input$brush_8,allRows = TRUE)
vals$keeprows = Res$selected_
})
observeEvent(input$brush_9,{
Res=brushedPoints(D(),input$brush_9,allRows = TRUE)
vals$keeprows = Res$selected_
})
observeEvent(input$brush_10,{
Res=brushedPoints(D(),input$brush_10,allRows = TRUE)
vals$keeprows = Res$selected_
})
observeEvent(input$brush_11,{
Res=brushedPoints(D(),input$brush_11,allRows = TRUE)
vals$keeprows = Res$selected_
})
observeEvent(input$brush_12,{
Res=brushedPoints(D(),input$brush_12,allRows = TRUE)
vals$keeprows = Res$selected_
})
我發現這個代碼在shiny_0.14.1(windows 7)中工作,但不在shiny_0.13.1(Redhat)中工作。你認爲它與包版本或操作系統有關嗎? – John
在shiny_0.13.1(Redhat,R版本3.1.3)中,'lapply'適用於'sliderInput's,但不適用於'observeEvent's。 – John
我沒有這個特定的版本,我測試過閃亮的0.13.2(R 3.2.0,redhat)它的工作原理,而閃亮的0.12.2(R 3.0.2,redhat)它不起作用,但與我的編輯它的作品。 – Victorp