R 闪亮布局

R Shiny Layouts

在我闪亮的仪表板中,我目前在上方绘制 1 个条形图,在下方绘制 4 个饼图,如下所示:

fluidRow(
  column(12, plotOutput("bar1"))),
  fluidRow(
    column(3, plotOutput("pie")),
    column(3, plotOutput("pie2")),
    column(3, plotOutput("pie3")),
    column(3, plotOutput("pie4")))

我将如何在 4 个饼图旁边绘制条形图,并将饼图排列成正方形?

实际上,条形图将是 column(6,...,所有饼图将是 column(3,...,但我需要将条形图扩展到 2 行,以便直接在其旁边绘制饼图.

标准 plotOutput 身高 400px

plotOutput(outputId, width = "100%", height = "400px", click = NULL,
dblclick = NULL, hover = NULL, hoverDelay = NULL, hoverDelayType = NULL, brush = NULL, clickId = NULL, hoverId = NULL, inline = FALSE)

因此您可以执行以下操作:

library(shiny)

ui <- fluidPage(
  fluidRow(
    column(6, plotOutput("bar1",height = "800px")),
    column(6,
           column(6, plotOutput("pie")),
           column(6, plotOutput("pie2")),
           column(6, plotOutput("pie3")),
           column(6, plotOutput("pie4"))

    ))
)

server <- function(input, output) {

  output$bar1 <- renderPlot({
    hist(rnorm(1:100));box();grid()
  })
  output$pie <- renderPlot({
    plot(rnorm(1:100));box();grid()
  })
  output$pie2 <- renderPlot({
    plot(rnorm(1:100));box();grid()
  })
  output$pie3 <- renderPlot({
    plot(rnorm(1:100));box();grid()
  })
  output$pie4 <- renderPlot({
    plot(rnorm(1:100));box();grid()
  })
}

shinyApp(ui,server)