Skip to content

Instantly share code, notes, and snippets.

@garrettgman
Created March 27, 2014 17:43

Revisions

  1. garrettgman created this gist Mar 27, 2014.
    39 changes: 39 additions & 0 deletions server.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    library(shiny)
    library(ggplot2)

    authorized <- TRUE

    shinyServer(function(input, output, session) {

    if (authorized) {
    data <- iris
    p <- qplot(Sepal.Width, Sepal.Length, data = iris, color = Species)
    output$ui <- renderUI({
    navbarPage(
    title = 'Permissions',
    tabPanel('Data', dataTableOutput('ex1')),
    tabPanel('Graph', plotOutput('ex2')),
    tabPanel('Authorized users only', h3('Only users with permission will see this tab')))
    })
    } else {
    data <- iris[ , -5]
    p <- qplot(Sepal.Width, Sepal.Length, data = iris)
    output$ui <- renderUI({
    navbarPage(
    title = 'Permissions',
    tabPanel('Data',
    h4("Login to see a species column"),
    dataTableOutput('ex1')),
    tabPanel('Graph',
    h4("Login to see clusters"),
    plotOutput('ex2'))
    )
    })
    }

    output$ex1 <- renderDataTable(data, options = list(iDisplayLength = 10))

    output$ex2 <- renderPlot({
    print(p)
    })
    })
    5 changes: 5 additions & 0 deletions ui.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    library(shiny)

    shinyUI(
    uiOutput('ui')
    )