Skip to content

Instantly share code, notes, and snippets.

View trestletech's full-sized avatar

Jeff Allen trestletech

View GitHub Profile
@trestletech
trestletech / server.R
Last active August 29, 2015 13:57 — forked from garrettgman/server.R
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(
@trestletech
trestletech / server.R
Last active February 2, 2022 09:47
A Shiny app combining the use of dplyr and SQLite. The goal is to demonstrate a full-fledged, database-backed user authorization framework in Shiny.
library(shiny)
library(dplyr)
library(lubridate)
# Load libraries and functions needed to create SQLite databases.
library(RSQLite)
library(RSQLite.extfuns)
saveSQLite <- function(data, name){
path <- dplyr:::db_location(filename=paste0(name, ".sqlite"))
@trestletech
trestletech / server.R
Last active August 1, 2022 14:12
Sample Shiny application demonstrating usage of Shiny Server Pro's authentication feature to customize the app according to the privileges of the logged-in user.
library(shiny)
library(ggplot2)
# Get the current day of the month
dom <- 25
# Define the target for salespeople in our organization.
salesTarget <- 15000
# Set the seed so we always get the same data.
@trestletech
trestletech / server.R
Created March 25, 2014 21:49
Shiny App for testing run_as -- just displays the user the R process is running as.
library(shiny)
# Define server logic required to generate and plot a random distribution
shinyServer(function(input, output) {
# Expression that generates a plot of the distribution. The expression
# is wrapped in a call to renderPlot to indicate that:
#
# 1) It is "reactive" and therefore should be automatically
# re-executed when inputs change
@trestletech
trestletech / server.R
Created March 25, 2014 16:42
ConditionalPanel + Plot Shiny Resizing Bug
library(shiny)
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
print("Plotting");
Sys.sleep(1)
# generate and plot an rnorm distribution with the requested
# number of observations
@trestletech
trestletech / global.R
Last active May 30, 2017 10:44 — forked from jpd527/server.R
sortListInput <- function(inputId,data) {
tagList(
singleton(tags$head(tags$script(src = "js/sortList.js"))),
HTML(paste('
<script>
$(function() {
$( ".sortableList" ).sortable();
$( ".sortableList" ).disableSelection();
});
@trestletech
trestletech / server.R
Last active May 25, 2017 21:30
An example of doing prolonged, iterative computation in Shiny.
library(shiny)
shinyServer(function(input, output, session) {
# The number of iterations to perform
maxIter <- 50
# Track the start and elapsed time
startTime <- Sys.time()
output$elapsed <- renderText({
@trestletech
trestletech / Vagrantfile
Last active January 4, 2016 04:48
Setup Shiny in R 2.15.2 on Ubuntu
# -*- mode: ruby -*-
# vi: set ft=ruby :
######### Shiny Server Pro OpenLDAP Test VM #############
# This VM is based on a Ubuntu 12.04.3 x64 image. It
# will provision and install OpenLDAP (slapd) with the
# ldap-utils package and add some test data into the
# database. It's configured with the static IP address:
@trestletech
trestletech / server.R
Last active May 10, 2017 21:24
Shiny example with a custom layout that filters the 'mpg' dataset from the 'ggplot2' library and displays the output in a table.
library(shiny)
# Load the ggplot2 package which provides
# the 'mpg' dataset.
library(ggplot2)
# Define a server for the Shiny app
shinyServer(function(input, output) {
# Filter data based on selections
@trestletech
trestletech / global.R
Last active January 3, 2016 21:29
A Shiny example using a sliderInput in a sidebar layout with pre-processing done in global.R.
# Define a dataset globally which will be available
# both to the UI and to the server.
# Rely on the 'WorldPhones' dataset in the datasets
# package (which generally comes preloaded).
library(datasets)
# Trim out the non-consecutive year from