R由两列闪亮的两行

问题描述:

我想在两行两列布局中放置四个图。下面的代码返回两列一列。如何添加第二列?R由两列闪亮的两行

任何帮助表示赞赏。

ui <- shinyUI(
       fluidRow(
         column(6, 
           plotOutput(outputId = "hist1") 
         ), 
         column(6, 
           plotOutput(outputId = "hist2") 
         ) 
       ) 
) 

    server <- function(input,output){ 
      output$hist1 <- renderPlot({ 
        hist(rnorm(100,50,5)) 
      }) 
      output$hist2 <- renderPlot({ 
        hist(rnorm(100,75,5)) 
      }) 
      output$hist3 <- renderPlot({ 
        hist(rnorm(100,100,5)) 
      }) 
      output$hist4 <- renderPlot({ 
        hist(rnorm(100,125,5)) 
      }) 
    } 

    runApp(list(ui = ui, server = server)) 
+0

变化'shinyUI(fluidRow(...))''来shinyUI(fluidPage(fluidRow(...)))' – brittenb

+0

真棒,仅此而已。谢谢。 – Murray

从brittenb回答评论:fluidPage()需要添加。

ui <- shinyUI(
     fluidPage(
       fluidRow(
         column(6, 
           plotOutput(outputId = "hist1") 
         ), 
         column(6, 
           plotOutput(outputId = "hist2") 
         ) 
       ), 
       fluidRow(
         column(6, 
           plotOutput(outputId = "hist3") 
         ), 
         column(6, 
           plotOutput(outputId = "hist4") 
         ) 
       ) 
     ) 
) 

server <- function(input,output){ 
     output$hist1 <- renderPlot({ 
       hist(rnorm(100,50,5)) 
     }) 
     output$hist2 <- renderPlot({ 
       hist(rnorm(100,75,5)) 
     }) 
     output$hist3 <- renderPlot({ 
       hist(rnorm(100,100,5)) 
     }) 
     output$hist4 <- renderPlot({ 
       hist(rnorm(100,125,5)) 
     }) 
} 

runApp(list(ui = ui, server = server))