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
#' Randomly subsample a matrix or data frame. | |
#' | |
#' To randomly subsample, we are using the parametric option in the boot function | |
#' within the boot package. The 'parametric' option requires the specification of | |
#' a 'ran.gen' function to generate observations based on the original data and a list of | |
#' maximum likelihood estimators (MLE). We utilize this method, but instead of the | |
#' MLE, we instead pass the subsample_size. | |
#' | |
#' As noted in the boot documentation: Use of sim = "parametric" with a suitable ran.gen | |
#' allows the user to implement any types of nonparametric resampling which are not |
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 'mouse) | |
(xterm-mouse-mode t) | |
(defun track-mouse (e)) | |
;; Save all backup file in this directory. |
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
if [ -f ~/.bashrc ]; then | |
source ~/.bashrc | |
fi | |
# Creates symbolic links from various subfolders in ~/Dropbox/ to ~/ | |
# This allows for a more consistent structure across my many computers. | |
if [ ! -L ~/scripts ]; then | |
ln -s ~/Dropbox/scripts/ ~/scripts | |
fi |
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
PATH=~/scripts:/usr/local/bin:$PATH:/usr/local/texlive/2011/bin/x86_64-darwin:/usr/local/sbin | |
export PATH | |
# Never save or restore when running R | |
alias R='R --no-save --no-restore-data --quiet' |
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
install.packages("rgl", dep = TRUE) | |
Installing package(s) into ‘/usr/local/Cellar/r/2.14.1/R.framework/Versions/2.14/Resources/library’ | |
(as ‘lib’ is unspecified) | |
trying URL 'http://cran.fhcrc.org/src/contrib/rgl_0.92.798.tar.gz' | |
Content type 'application/x-gzip' length 1677772 bytes (1.6 Mb) | |
opened URL | |
================================================== | |
downloaded 1.6 Mb | |
* installing *source* package ‘rgl’ ... |
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
Rmd file to show the issue... | |
```{r rcpp} | |
library(Rcpp) | |
library(inline) | |
# C++ code to calculate the length of a vector. | |
src <- ' | |
Rcpp::NumericVector vec_x(x); | |
int n = vec_x.size(); |
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
#' Computes the quantile from flowClust for a given vector of probabilties | |
#' | |
#' We estimate the quantile from a \code{flowClust} fit with a combination of | |
#' numerical integration and a root-finding method. We are effectively | |
#' estimating the cumulative distribution function (CDF) of the mixture density | |
#' estimated by \code{flowClust}. | |
#' | |
#' Because we are using numerical methods, we also need an \code{interval} of | |
#' values in which we will attempt to find the specified quantile. | |
#' |
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
import requests | |
# The direct link to the Kaggle data set | |
data_url = 'http://www.kaggle.com/c/digit-recognizer/download/train.csv' | |
# The local path where the data set is saved. | |
local_filename = "train.csv" | |
# Kaggle Username and Password | |
kaggle_info = {'UserName': "my_username", 'Password': "my_password"} |
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
#' Finds the local maxima (peaks) in the given vector after smoothing the data | |
#' with a kernel density estimator. | |
#' | |
#' First, we smooth the data using kernel density estimation (KDE) with the | |
#' \code{\link{density}} function. Then, we find all the local maxima such that | |
#' the density is concave (downward). | |
#' | |
#' Effectively, we find the local maxima with a discrete analogue to a second | |
#' derivative applied to the KDE. For details, see this StackOverflow post: | |
#' \url{http://bit.ly/Zbl7LV}. |
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
tidy.source(source = "messy-code.r", file = "tidy-code.r", width.cutoff = 80, reindent.spaces = 2) |