Skip to content

Instantly share code, notes, and snippets.

@trestletech
Forked from garrettgman/server.R
Last active August 29, 2015 13:57
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/9817054 to your computer and use it in GitHub Desktop.
Save trestletech/9817054 to your computer and use it in GitHub Desktop.
library(shiny)
library(ggplot2)
shinyServer(function(input, output, session) {
if (!is.null(session$user)) {
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')),
tabPanel('Login', a(href="./__login__", "Login here"))
)
})
}
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