Gambler’s Run With Shiny

May 8, 2013
By

(This article was first published on Jason.Bryer.org Blog - R, and kindly contributed to R-bloggers)

I finally had an opportunity to play with Shiny, and I am very impressed. I have created a Github Project so head over there for the source code. There are a number of ways to distribute Shiny apps. If you are running R (and mostly likely you are if you are reading this), you can download and run Shiny apps using the runApp (if already downloaded), runGitHub, runGist, or runUrl functions. RStudio also make the Shiny Server available and you can also request an account on their servers. Also be sure to check out the excellent tutorial on Shiny.

First, install shiny and shinyIncubator (for the ActionButton) packages, preferably the development versions.

require(devtools)
install_github('shiny', 'rstudio')
install_github('shiny-incubator', 'rstudio')
require(shiny)

Gambler’s Run

This simple app that lets you simulate a sequence of random events, for example coin flips, and plot the cummulative sum. This app allows you choose the odds of winning, the number of games to simulate, and the number of simulations to display simultaneously.

Gambler Shiny App

To run the app locally:

shiny::runGitHub('ShinyApps', 'jbryer', subdir='gambler')

Or from the RStudio server (note that RStudio does not guarantee the server will always be up so this link may or may not work).

Lottery Tickets

Similar to the gambler app, this simulates buying a series of lottery tickets with varying odds of winning different amounts. Each previous run is saved and plotted in light grey to show how the current run compares to past runs.

Lottery Tickets Shiny App

To run the app locally:

shiny::runGitHub('ShinyApps', 'jbryer', subdir='lottery')

Or from the RStudio server (note that RStudio does not guarantee the server will always be up so this link may or may not work).

Just to try out all the ways to distribute Shiny apps, I also created a Gist for this app.

shiny::runGist("5525690")

To leave a comment for the author, please follow the link and comment on his blog: Jason.Bryer.org Blog - R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.