Skip to content

Instantly share code, notes, and snippets.

@trestletech
Forked from garrettgman/server.R
Created March 31, 2014 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trestletech/9895574 to your computer and use it in GitHub Desktop.
Save trestletech/9895574 to your computer and use it in GitHub Desktop.
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)
})
})
library(shiny)
shinyUI(
uiOutput('ui')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment