1
我有依賴於用戶的輸入的曲線圖。 根據輸入,繪圖大小將有所不同。閃亮plotOutput動態特性
我可以動態控制繪圖的高度? 我知道,在我plotOutput()
的高度的說法,但我不能找到一種方法來動態地改變它。
重複的例子,當你選擇A,情節看起來不錯,但如果你選b,它更以高
library(shiny)
library(ggplot2)
df1 <- data.frame(x = 1:2000, y = rnorm(2000), type = rep(LETTERS[1:8], 250))
df2 <- data.frame(x = 1:100, y = rexp (100), type = rep(c('A','B'), 50))
ui <- shinyUI(fluidPage(title = '',
fluidRow(selectInput("table",'', choices = c('A','B'))),
fluidRow(plotOutput("my_plot", height = '1000px'))
)
)
server <- shinyServer(function(input, output) {
output$my_plot <- renderPlot({
t <- if(input$table == 'A') df1
else df2
ggplot(t) + facet_grid(type~.) +
geom_point(mapping = aes(x=x, y=y))
}
)
})
shinyApp(ui, server)
最後一兩件事,在實際應用這並不是說我有2個不同尺寸,這取決於尺寸需要改變的輸入。
非常感謝您! 我不知道我可以在服務器中呈現。 完美:) –