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
# http://trinkerrstuff.wordpress.com/2014/05/12/handling-s3methods-death-in-roxygen-4-0-0/ | |
pth <- "C:/Users/trinker/qdap/R" | |
fls <- file.path(pth, dir(pth)) | |
FUN <- function(x) { | |
cont <- readLines(x) | |
cont[grepl("#' @S3", cont)] <- "#' @export" | |
cont[length(cont) + 1] <- "" |
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
# check if you need to install these packages | |
pkg <- c("RODBC", "ggplot2") | |
inst <- pkg %in% installed.packages() | |
# inst | |
if (length(pkg[!inst]) > 0) { | |
install.packages(pkg[!inst]) | |
} | |
# load all required packages into session | |
lapply(pkg, library, character.only = TRUE) |
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
# solarized light color scheme for my TexShop setup | |
defaults write TeXShop background_R 0.99 | |
defaults write TeXShop background_G 0.96 | |
defaults write TeXShop background_B 0.89 | |
defaults write TeXShop commandred 0.0 | |
defaults write TeXShop commandgreen 0.0 | |
defaults write TeXShop commandblue 1.0 |
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
# Note: using the devel versions of both packages! | |
library(DESeq) # version 1.9.11 | |
library(edgeR) # version 2.99.8 | |
library(VennDiagram) | |
# Read in data ------------------------------------------------------------ | |
## Use pasilla data | |
datafile = system.file( "extdata/pasilla_gene_counts.tsv", package="pasilla" ) | |
datafile |
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
## I came across a Chinese science blog which discusses an interesting stuff that girls should reject | |
## the first 37% (for 1/e = 36.79%) pursuers in her life. A little R simulation as outlined in the | |
## gist is shown below just for fun. In the snippet, m is the total number of boys you can choose. | |
## In other words, they are potential husband for you. Larger number means high "quality" but these | |
## numbers are randomly sampled, i.e., you don’t know whether the one who just walks into your life | |
## is your Mr. Right or not. You reject the first m/e people (probably without any reason...), where | |
## e is the Euler’s number, and choose from the rest of the m people. If you find any one of the | |
## remaning boys better than the best boy you saw earlier in the first m/e ones, then you choose that | |
## guy; otherwise, you have to make do with the last guy for the rest of your life... |
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
# A simple approach to visually-weighted regression plots | |
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("ggplot2", "reshape2", "MASS") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Generate some data: | |
nn <- 1000 | |
myData <- data.frame(X = rnorm(nn), |
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
# Simple ggplot2 heatmap | |
# with colorBrewer "spectral" palette | |
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("ggplot2", "reshape2", "RColorBrewer") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Generate a random matrix | |
# This can be any type of numeric matrix, |
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 allocating observations into groups, for, e.g. cross-validation | |
kk <- 10 # Number of partitions, as in "kk-fold cross-validation." | |
# Here is a data.frame full of good data: | |
nn <- 1003 | |
myData <- data.frame(matrix(rnorm(nn * 3), ncol = 3)) | |
colnames(myData) <- LETTERS[1:3] | |
# This does not work: | |
whichK <- sample(LETTERS[1:kk], nrow(myData), replace = T) |
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
#' 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), |
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
# Simple ggplot2 heatmap, with optimal seriation | |
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("ggplot2", "reshape2", "RColorBrewer", "seriation") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Using U.S. Judge Rating Data | |
myData <- as.matrix(USJudgeRatings) |
OlderNewer