2016-11-18 9 views
1

2行×2列のレイアウトで4つのプロットを配置したいと思います。以下のコードは、2つの行を1つの列で返します。 2番目の列はどのように追加できますか?R光沢のある2行×2列

何か助けていただければ幸いです。

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(...)) '' – brittenb

+0

素晴らしい、それはそれです。ありがとう。 – Murray

答えて

0

コメントの中のbrittenbからの回答:fluidPage()を追加する必要があります。 `shinyUI(fluidPage(fluidRow(...)))へ

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)) 
関連する問題