Combining layout functions

To finish, let's look at how to use different layout functions together to achieve a simple and flexible setup for your application. There are lots of different ways of doing this; this example is designed just to show you that you can use a wide variety of functions to write quick, simple code. In truth, any design can be made using the grid system, given enough time and effort, but it is sometimes simpler just to use a built-in function, as you can see. In this example, I've added a couple of graphs to flesh out the interface a bit, but we won't bother looking at the code for them. They're just created using renderPlot({plot(runif(10, runif(10))}) and assigned to output$graph1 and output$graph2. The final UI code looks like this:

ui = fluidPage(
fluidRow(
column(width = 4,
sliderInput("slider", "Slider", min = 1, max = 100, value = 50)),
column(width = 8,
tableOutput("table")
)
),
splitLayout(
plotOutput("graph1"), plotOutput("graph2")
),
verticalLayout(
textInput("text", "Text"),
p("More details here"),
a(href = "https://shiny.rstudio.com/tutorial/", "Shiny documentation")
)
)

As you can see, you can freely mix together these layout functions to take advantage of the benefits of each; fluidRow() to give precise control over the width of the columns, splitLayout() for simplicity, and verticalLayout() to stack the widgets on top of each other. The final application looks like the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset