Complete

Now, we come to the complete setup functions, those that can be used individually to make a well-styled application. First, of course, we have the old favorite, sidebarLayout(). Many, many Shiny applications are written using this layout and it is an attractive and functional setup, with a well panel that highlights the controls and a large area for one or more outputs. We've already seen this setup, but as a quick review of the basic structure without all the usual clutter, let's take a look at the ui code:

ui = fluidPage(
sidebarLayout(
sidebarPanel(
sliderInput("slider", "Slider", min = 1, max = 100, value = 50),
textInput("text", "Text")),
mainPanel(tableOutput("table"))
)
)

It's worth noting that this layout requires the use of fluidPage() to set it up correctly. This function is required for this and another layout function, which we will cover shortly, as well as being useful in its own right (which we will also cover shortly).

The other two complete layout functions are navbarPOAge() and navlistPanel(). They work similarly in that both provide buttons for you to page through sets of input and output. Let's look at each. Here is the same set of input and output, put together as a navbar:

Navbar

This is one of the selected pages, Inputs. The table is viewable on the Table page, accessed by clicking the Table button on the bar at the top. This is obviously not particularly good UI design, it's just done to illustrate how the functions work.

The code is very simple and just consists of tab panels, like you would find in tabsetPanel():

ui = navbarPage("Navbar demo",
tabPanel("Inputs",
sliderInput("slider", "Slider",
min = 1, max = 100, value = 50),
textInput("text", "Text")),
tabPanel("Table", tableOutput("table"))
)

Navlists work in a pretty similar way, except the pages for the buttons are gathered over on the left, as shown in the following screenshot:

The code here is very similar, except in this case, as with the sidebarLayout() function, a call to fluidPage() is necessary:

ui = fluidPage(
navlistPanel("Navlist demo",
tabPanel("Inputs",
sliderInput("slider", "Slider",
min = 1, max = 100, value = 50),
textInput("text", "Text")),
tabPanel("Table", tableOutput("table"))
)
)
..................Content has been hidden....................

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