R 反应图大小,有光泽
是否有可能在shiny中使用反应性绘图大小 下面是一个小例子,我希望它如何工作。但它给出了一个错误,因为被动表达式不在输出中 在ui.R中,您可以选择宽度和两个打印输出:R 反应图大小,有光泽,r,plot,shiny,R,Plot,Shiny,是否有可能在shiny中使用反应性绘图大小 下面是一个小例子,我希望它如何工作。但它给出了一个错误,因为被动表达式不在输出中 在ui.R中,您可以选择宽度和两个打印输出: shinyUI(pageWithSidebar( headerPanel("Title"), sidebarPanel( selectInput("width", "Choose width:", choices = c("200", "400")) ), mainPanel( plo
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%")
)
))
服务器.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() )
})
shinyServer(函数(输入、输出){
x你的收尾,试试这个:
ui <- shinyUI(pageWithSidebar(
headerPanel("Title"),
sidebarPanel(
selectInput("direction", "Choose width:",
choices = c("200", "400"))
),
mainPanel(
plotOutput(outputId = "main_plot", width = "100%"),
plotOutput(outputId = "main_plot2", width = "100%")
)
))
server <- shinyServer(function(input, output) {
x <- 1:10
y <- x^2
output$main_plot <- renderPlot({
plot(x, y)}, height = 200, width = 400)
observe({
output$main_plot2 <- renderPlot({
plot(x, y) }, height = 200, width = as.numeric(input$direction))
})
})
shinyApp(ui=ui,server=server)
ui您的关闭,请尝试以下操作:
ui <- shinyUI(pageWithSidebar(
headerPanel("Title"),
sidebarPanel(
selectInput("direction", "Choose width:",
choices = c("200", "400"))
),
mainPanel(
plotOutput(outputId = "main_plot", width = "100%"),
plotOutput(outputId = "main_plot2", width = "100%")
)
))
server <- shinyServer(function(input, output) {
x <- 1:10
y <- x^2
output$main_plot <- renderPlot({
plot(x, y)}, height = 200, width = 400)
observe({
output$main_plot2 <- renderPlot({
plot(x, y) }, height = 200, width = as.numeric(input$direction))
})
})
shinyApp(ui=ui,server=server)
ui-Argh,所以这只是复制粘贴失败…非常感谢您的澄清!:)Argh,所以这只是复制粘贴失败…非常感谢您的澄清!:)