0
我做了一個閃亮的應用程序中移除了邊遠試驗中的人爲:光澤:操縱全局變量輸入回閃亮
df=data.frame(seq(-1000,1000), rnorm(2001)) #not real data
ui <- basicPage(
plotOutput("plot1", click = "plot_click", brush = "plot_brush"),
verbatimTextOutput("info"),
plotOutput("tab")
)
server <- function(input, output) {
output$plot1 <- renderPlot({
plot(df[,1], df[,2])
})
data_new<-eventReactive(input$plot_brush,{
da=df
rowmin <- which(da[,1] == round(as.numeric(input$plot_brush$xmin)))
rowmax <- which(da[,1] == round(as.numeric(input$plot_brush$xmax)))
da[rowmin:rowmax,2] = mean(da[,2])
da=isolate(da)
#writeToDatabase(da)
})
#output$zoom<-renderable({plot(data_new()[,1], data_new()[,2])})
output$tab=renderPlot({plot(data_new()[,1], data_new()[,2])})
}
shinyApp(ui, server)
這工作得很好,但實在是不方便,我不能永久刪除那麼我想知道的是什麼方法可以使非反應變量的值永久保留所做的更改,而不是每次都重新繪製原始不正確的數據幀?
我已經使用糾正這個錯誤的數據變量「DF」功能的嘗試:
change=reactive(function(d){
rowmin <- which(d[,1] == round(as.numeric(input$plot_brush$xmin)))
rowmax <- which(d[,1] == round(as.numeric(input$plot_brush$xmax)))
d[rowmin:rowmax,2] = mean(d[,2])
return(isolate(d))
})
isolate(change(df))
,但我得到了以下錯誤:
Listening on http://127.0.0.1:6183
Warning: Error in change: unused argument (df)
Stack trace (innermost first):
52: change
51: is.data.frame
50: write.table
43: isolate
42: server [/Users/Downloads/test.R#20]
1: runApp
Error in change(df) : unused argument (df)
這是一個入門測試,看看我可以動態更新變量。所有這些都是爲了能夠連續查看和消除上面顯示的數據中的每個尖銳錯誤峯值,而不是每次都在同一個不可變(從閃亮的角度來看)變量上重新運行的代碼。