Skip to content

Instantly share code, notes, and snippets.


Jason Bryer jbryer

View GitHub Profile
View Login.R
# This script is modified by Jason Bryer ( from Huidong Tian's
# original script. The blog post describing the method is here:
# The original R script is located here:
# This script adds two new features: 1. Render a logout button, and 2. provide
# the ability for visitors to create a new account.
# Within your server.R file, be sure to use:
jbryer / 2013-08-B.txt
Created Feb 21, 2016
View 2013-08-B.txt
From San Francisco to New York to Paris, city governments, high-class restaurants,
schools, and religious groups are ditching bottled water in favor of what comes out of the
faucet. With people no longer content to pay 1,000 times as much for bottled water, a
product no better than water from the tap, a backlash against bottled water is growing.
(5) The U.S. Conference of Mayors, which represents some 1,100 American cities,
discussed at its June 2007 meeting the irony of purchasing bottled water for city employees
and for city functions while at the same time touting1 the quality of municipal water. The
group passed a resolution sponsored by Mayors Gavin Newsom of San Francisco, Rocky
Anderson of Salt Lake City, and R. T. Rybak of Minneapolis that called for the examination
(10) of bottled water’s environmental impact. The resolution noted that with $43 billion a year
jbryer / strtable.R
Last active Nov 20, 2019
Implementation of the str function to return a data.frame
View strtable.R
#' Creates a \code{data.frame} version of the str function for data.frames.
#' Note that this function only works with \code{data.frames}. The function
#' will throw an error for any other object types.
#' @param n the first n element to show
#' @param width maximum width in characters for the examples to show
#' @param n.levels the first n levels of a factor to show.
#' @param width.levels maximum width in characters for the number of levels to show.
#' @param factor.values function defining how factor examples should be printed.
#' Convert a list of vectors to a data frame.
#' This function will convert a list of vectors to a data frame. This function
#' will handle three different types of lists of vectors. First, if all the elements
#' in the list are named vectors, the resulting data frame will have have a number
#' of columns equal to the number of unique names across all vectors. In cases
#' where some vectors do not have names in other vectors, those values will be
#' filled with \code{NA}.
#' The second case is when all the vectors are of the same length. In this case,
View package.R
#' Simplified loading and installing of packages
#' This is a wrapper to \code{\link{require}} and \code{\link{install.packages}}.
#' Specifically, this will first try to load the package(s) and if not found
#' it will install then load the packages. Additionally, if the
#' \code{update=TRUE} parameter is specified it will check the currently
#' installed package version with what is available on CRAN (or mirror) and
#' install the newer version.
#' @param pkgs a character vector with the names of the packages to load.
jbryer / getYearQuarter.R
Created Apr 18, 2013
Returns the quarter in which the date appears.
View getYearQuarter.R
#' Returns the year (fiscal or calendar) and quarter in which the date appears.
#' This function will cut the given date vector into quarters (i.e. three month
#' increments) and return an ordered factor with levels defined to be the quarters
#' between the minimum and maximum dates in the given vector. The levels, by
#' default, will be formated as \code{FY2013-Q1}, however the \code{FY} and \code{Q}
#' can be changed using the \code{fy.prefix} and \code{quarter.prefix} parameters,
#' respectively.
#' @param x vector of type \code{\link{Date}}.
jbryer / DisneyMarathonWeather.R
Last active Oct 2, 2018
Disney Marathon Weather in ggplot2
View DisneyMarathonWeather.R
weather <- read.csv('DisneyMarathonWeather.csv')
weather.melt <- melt(weather[,c('Year', 'Low', 'High', 'Wind', 'StartHumidity', 'Sky')],
id.vars = c('Year', 'Wind', 'StartHumidity', 'Sky'))
ggplot(weather.melt, aes(x = Year)) +
geom_ribbon(data = weather, aes(ymin = Low, ymax = High), alpha = 0.3, fill = 'skyblue') +
geom_path(aes(y = value, group = variable)) +
jbryer / server.R
Last active Dec 22, 2017
Shiny Example of Gambler's Run
View server.R
tickets <-
c( '$1', 1, 15),
jbryer / setup.r
Created Mar 7, 2012
R Setup Script
View setup.r
#List of most used R packages that we wish to install.
libraries = c('cacheSweave', 'Deducer', 'devtools', 'doBy', 'foreign', 'gdata',
'ggplot2', 'Hmisc', 'JGR', 'lubridate', 'maps', 'mapdata', 'mapproj',
'maptools', 'proto', 'psych', 'R2wd', 'RCurl', 'reshape',
'RODBC', 'roxygen2', 'seqinr', 'sm', 'sp', 'sqldf', 'survey',
'WriteXLS', 'XML', 'xtable')
#We will install packages from the main CRAN site
repos = ''
#Site provides some prebuilt binaries for Windows
jbryer / xtable.decimal.r
Last active Jun 29, 2017
Prints a LaTeX table with numeric columns aligned on their decimal points. This function wraps the xtable and print.xtable functions in the xtable package so that numeric columns are aligned on their decimal place.
View xtable.decimal.r
#' Prints a LaTeX table with numeric columns aligned on their decimal points.
#' This function wraps the \code{\link{xtable}} and \code{\link{print.xtable}}
#' functions in the \code{xtable} package so that numeric columns are aligned
#' on their decimal place.
#' See \url{}
#' for more information.
You can’t perform that action at this time.