Skip to content

Instantly share code, notes, and snippets.


Jason Bryer jbryer

View GitHub Profile
jbryer / server.R
Last active Dec 22, 2017
Shiny Example of Gambler's Run
View server.R
tickets <-
c( '$1', 1, 15),
jbryer / parse.codebook.r
Last active Nov 3, 2016
Parses a codebook file where lines starting at column zero (far left) represet variable information (e.g. name, description, type) and indented lines (i.e. lines beginning with white space, either tabs or spaces, etc.) represent factor levels and labels.
View parse.codebook.r
#' Parse a codebook file with variable and level information.
#' Parses a codebook file where lines starting at column zero (far left) represet
#' variable information (e.g. name, description, type) and indented lines
#' (i.e. lines beginning with white space, either tabs or spaces, etc.) represent factor
#' levels and labels.
#' Note that white space at the beginning and end of each line is stripped before
#' processing that line.
jbryer / varEntryDialog.r
Created Aug 13, 2012
Function to create a tcl/tk dialog box for a user to enter variable values.
View varEntryDialog.r
#' Creates a dialog box using tcl/tk to get input from the user.
#' This function will create a tcl/tk dialog box to get user input. It has been
#' written to be extensible so the R programmer can easily create a dialog with
#' any number of varaibles with custom labels and data conversion of the user
#' entered data. The function will return a list where the element names are
#' \code{vars} and the value is the user input. By default, all entry will be
#' converted using the \code{as.character} function. However, this can easily be
#' altered using the \code{fun} parameter. For example, if integers are required,
#' use \code{fun=c(as.integer, ...)}. It is also possible to write custom
jbryer / setFunctionParams.R
Created Jul 15, 2013
Set function parameters within the global environment. Useful for debugging R functions.
View setFunctionParams.R
#' Set function parameters for debugging.
#' Sets the defauls for the parameters in the given function witin an environment.
#' @param fun the function whose parameters should be set.
#' @param envir the environment to set those parameters.
#' @param missing.value value to assign to parameters that do not have a defautl value.
#' @param overwrite should parameters already defined be overwritten.
setFunctionParams <- function(fun,
jbryer / ggplot2Cheat.r
Created Apr 26, 2012
Graphic Parameters (symbols, line types, and colors) for ggplot2
View ggplot2Cheat.r
#Borrowed (i.e. stollen) from
getColorHexAndDecimal <- function(color) {
if( {
jbryer / Rprofile.R
Created Mar 7, 2012
My .Rprofile that works both on Windows and Linux
View Rprofile.R
# .Rprofile -- commands in this file will be executed at the beginning of
# each R session. On Windows, the R_PROFILE environment variable must have value
# with the full path to this file. On Linux (or other Unix like systems) this file
# must be in the user's home directory.
# Set the default repository to the main CRAN site
# Set the oDrive varaible and library path
if(['sysname'] == 'Windows') {
jbryer / BirthdayProblem.R
Created Jan 31, 2012
Given a room with n people in it, what is the probability any two will have the same birthday?
View BirthdayProblem.R
## See for an explanation of the problem
birthday <- function(n) {
1 - exp( - n^2 / (2 * 365) )
jbryer / EmailClass.R
Created Jan 20, 2012
Example of object oriented programming in R
View EmailClass.R
#' Constructor
EmailClass <- function(name, email) {
nc = list(
name = name,
email = email,
get = function(x) nc[[x]],
set = function(x, value) nc[[x]] <<- value,
props = list(),
history = list(),
getHistory = function() return(nc$history),
jbryer / GoogleReader.R
Created Jan 13, 2012
Function to return an RSS feed using the (unofficial) Google Reader API
View GoogleReader.R
#' This function ruturns an XML tree of the RSS feed from the given URL.
#' This function utilizes the (unofficial) Google Reader API to retrieve RSS
#' feeds. The advantage of access RSS feeds through the Google Reader API is that
#' you are not limited by the number of entries a website may included in their
#' feed. That is, Google maintains generally maintains a complete history of
#' entries from the RSS feed.
jbryer / RBloggers.R
Created Jan 13, 2012
Retrieving and Analyzing R-Bloggers using the Google Reader API
View RBloggers.R
rbloggers = getRSSFeed(feedURL="",
entries = rbloggers[which(names(rbloggers) == "entry")]
saveXML(rbloggers, file='rbloggers.xml')