【发布时间】:2016-01-28 15:10:02
【问题描述】:
嗨,我的第二周闪亮。我正在编写一个应用程序,其中一个绘图窗口和一些绘图控制按钮需要在某个时候出现。我使用renderUI() 和renderPlot()。我可以让用户更新绘图参数renderPlot(expr={ [inside here] })。
,但我不能让用户更改绘图分辨率renderPlot(res=[some reactive variable outside here],expr={ })
我已经在下面发布了测试示例,非常感谢。
library(shiny)
ui = fluidPage(
uiOutput('thisPlot'),
uiOutput('plotOptions')
)
server <- function(input, output) {
#some plot options which will appear by some event
output$plotOptions <- renderUI({
if(TRUE) {list(
radioButtons('plot.log', 'log axis',
c('none'= '' ,
'x' = 'x',
'y' = 'y',
'xy' = 'xy'),sel=NULL),
sliderInput('plotRes', "resolution",min=50,max=200,value=75)
)}
})
#render plot // plotRes does not respond
output$thisGraphicsDev <- renderPlot(res=input$plotRes,expr={
plot(x=runif(1000),y=runif(1000),log=input$plot.log)
})
#write plot to ui
output$thisPlot <- renderUI({plotOutput('thisGraphicsDev')})
}
shinyApp(ui, server)
【问题讨论】: