Skip to content

Commit

Permalink
exemplos layout shiny
Browse files Browse the repository at this point in the history
  • Loading branch information
williamorim committed Apr 4, 2024
1 parent 1538bf6 commit 5b6af4c
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
5 changes: 2 additions & 3 deletions curso_gravado/scripts/16-sidebarLayout.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ui <- fluidPage(
)
),
mainPanel = mainPanel(
plotOutput(outputId = "grafico")
plotOutput("grafico")
)
)
)
Expand All @@ -24,5 +24,4 @@ server <- function(input, output, session) {

}

shinyApp(ui, server)

shinyApp(ui, server)
77 changes: 77 additions & 0 deletions curso_gravado/scripts/17-navbarPage.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
library(shiny)

ui <- navbarPage(
title = "navbar Page",
tabPanel(
title = "Página 1",
titlePanel("Título da página 1"),
fluidRow(
column(
width = 6,
plotOutput("grafico1")
),
column(
width = 6,
tableOutput("tabela")
)
)
),
tabPanel(
title = "Página 2",
titlePanel("Título da página 2"),
sidebarLayout(
sidebarPanel(
selectInput(
inputId = "variavel",
label = "Selecione uma variável",
choices = names(mtcars)
)
),
mainPanel(
plotOutput("grafico2")
)
)
),
navbarMenu(
title = "Várias páginas",
tabPanel(
title = "Página 3",
titlePanel("Título da página 3")
),
tabPanel(
title = "Página 4",
titlePanel("Título da página 4")
),
tabPanel(
title = "Página 5",
titlePanel("Título da página 5")
)
)
)

server <- function(input, output, session) {

output$grafico1 <- renderPlot({
plot(x = mtcars[["wt"]], y = mtcars[["mpg"]])
})

output$grafico2 <- renderPlot({
plot(x = mtcars[[input$variavel]], y = mtcars[["mpg"]])
})

output$tabela <- renderTable({
mtcars |>
dplyr::filter(mpg > mean(mpg))
})

}

shinyApp(ui, server)








0 comments on commit 5b6af4c

Please sign in to comment.