Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny layout - how to add footer disclaimer?

Tags:

html

r

shiny

How can I add footer notes or disclaimer in Shiny's UI? This is my current layout,

shinyUI(
  pageWithSidebar(

    headerPanel("My Title"),

    sidebarPanel("sidebar"),

    mainPanel("hello world")
)
)

I have checked this page but no mention of this. Any ideas?

What I need is,

My Title

sidebar   hello world (plots)

----------------------------

      disclaimer
like image 240
Run Avatar asked May 13 '15 03:05

Run


1 Answers

Here is an example for other Shiny happy people to use.

Note that I have updated the above example to sidebarLayout as ?pageWithSidebar help states:

pageWithSidebar - This function is deprecated. You should use fluidPage along with sidebarLayout to implement a page with a sidebar.

Basic example of footer

I have made example the all in one app.r style so people can test this, but if you have a ui.R file just add a row just before end of your fluidPage call. I use a horizontal rule (hr) just before the footer to make the footer stand out, but this is up to you. I notice navbarPage has a header and footer parameter you can set.

# app.R
library(shiny)

ui<- shinyUI(
    fluidPage(
        title = "Footer example App",
        sidebarLayout(
            sidebarPanel(
                "sidebar",
                selectInput(
                    "pet",
                    "Pet", 
                    c("Cat", "Dog", "Fish")
                )
            ),
            mainPanel("hello world")
        ),
        # WHERE YOUR FOOTER GOES
        hr(),
        print("~~~my disclaimer~~~~")
    )
)

server <- function(input, output) {
  # empty for minimal example
}

shinyApp(ui=ui, server = server)

Result

FooterInBrowser

More advanced using footer.html

I have my own footer.html file with css and logo stylings. Place your footer.html file in your same place as your shiny files and use includeHTML. I wrap with a div so any css gets picked up.

In above example, replace line:

    print("~~~my disclaimer~~~~")

With:

    div(
        class = "footer",
        includeHTML("footer.html")
    )
like image 80
micstr Avatar answered Sep 20 '22 00:09

micstr