【发布时间】:2016-01-28 06:19:00
【问题描述】:
是否有可能以某种方式在闪亮中具有反应性绘图大小?
这是一个小例子,我希望它如何工作。尽管响应式表达式不在输出中,但它会给出错误。
ui.R,您可以在其中选择宽度和两个绘图输出:
shinyUI(pageWithSidebar(
headerPanel("Title"),
sidebarPanel(
selectInput("width", "Choose width:",
choices = c("200", "400"))
),
mainPanel(
plotOutput(outputId = "main_plot", width = "100%"),
plotOutput(outputId = "main_plot2", width = "100%")
)
))
server.R,其中第二个绘图应具有输入宽度:
shinyServer(function(input, output) {
x <- 1:10
y <- x^2
width <- reactive({
switch(input$direction,
'200' = 200,
'400' = 400)
})
output$main_plot <- renderPlot({
plot(x, y)}, height = 200, width = 400)
output$main_plot2 <- renderPlot({
plot(x, y) }, height = 200, width = width() )
})
【问题讨论】: