Skip to content

Instantly share code, notes, and snippets.

@pdurbin
Last active October 15, 2015 18:25
Show Gist options
  • Save pdurbin/115bf6a0194c58bac9dc to your computer and use it in GitHub Desktop.
Save pdurbin/115bf6a0194c58bac9dc to your computer and use it in GitHub Desktop.
Shiny installed via RPM

Shiny installed via RPM

After running vagrant up you should be able to visit http://localhost:3838/sample-apps/hello/ and see "Shiny installed via RPM" at the top and a histogram with black bins similar to the "screenshot.png" found in this directory.

The setup is done by setup.sh and operates on files within the Vagrant VM in "/shiny-setup". See Vagrantfile in this directory for details.

This proof of concept uses the following software versions:

  • CentOS 6.5
  • R 3.2.2
  • shiny 0.12.2
  • shiny-server 1.2.3
install.packages("shiny", repos=c("http://lib.stat.cmu.edu/R/CRAN/", "http://cran.wustl.edu", "http://cran.us.r-project.org"))
library(shiny)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
# Expression that generates a histogram. 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
# 2) Its output type is a plot
output$distPlot <- renderPlot({
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'black', border = 'white')
})
})
#!/bin/sh
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6Server/x86_64/epel-release-6-8.noarch.rpm
yum install -y R
Rscript /shiny-setup/install-shiny-package.R
yum -y install --nogpgcheck http://download3.rstudio.org/centos-5.9/x86_64/shiny-server-1.2.3.368-x86_64.rpm
cp /opt/shiny-server/config/init.d/redhat/shiny-server /etc/init.d
chkconfig --add shiny-server
chkconfig shiny-server on
cp /shiny-setup/ui.R /shiny-setup/server.R /opt/shiny-server/samples/sample-apps/hello
library(shiny)
# Define UI for application that plots random distributions
shinyUI(pageWithSidebar(
# Application title
headerPanel("Shiny installed via RPM"),
# Sidebar with a slider input for number of observations
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot", height=250)
)
))
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "puppet-vagrant-boxes.puppetlabs.com-centos-65-x64-virtualbox-puppet.box"
config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-puppet.box"
config.vm.synced_folder ".", "/shiny-setup"
config.vm.provision "shell", path: "setup.sh"
config.vm.network "forwarded_port", guest: 3838, host: 3838
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment