This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' 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, | |
envir=.GlobalEnv, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(shiny) | |
require(shinyIncubator) | |
require(ggplot2) | |
theme_update(panel.background=element_blank(), | |
panel.grid.major=element_blank(), | |
panel.border=element_blank()) | |
tickets <- as.data.frame(rbind( | |
c( '$1', 1, 15), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' 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}}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' 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. | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(xtable) | |
#' 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{http://jason.bryer.org/posts/2013-01-04/xtable_with_aligned_decimals.html} | |
#' for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(ggplot2) | |
require(grid) | |
theme_update(panel.background=theme_blank(), | |
panel.grid.major=theme_blank(), | |
panel.border=theme_blank()) | |
#Borrowed (i.e. stollen) from http://research.stowers-institute.org/efg/R/Color/Chart/ColorChart.R | |
getColorHexAndDecimal <- function(color) { | |
if(is.na(color)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .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 | |
options(repos=c(CRAN='http://cran.r-project.org')) | |
# Set the oDrive varaible and library path | |
if(Sys.info()['sysname'] == 'Windows') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 = 'http://cran.r-project.org' | |
#Site provides some prebuilt binaries for Windows |