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
My message: | |
This was tweeted recently by an R user, and after trying to figure out why this is, I am stumped: | |
> a <- 5; b <- 1; c <- 4 | |
> f <- function (n) for (i in 1:n) d <- 1/{a*{b+c}} | |
> g <- function (n) for (i in 1:n) d <- 1/(a*(b+c)) | |
> system.time(f(1000000)) | |
user system elapsed | |
3.92 0.00 3.94 | |
> system.time(g(1000000)) | |
user system elapsed |
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
tracked <- new.env() | |
makeCounted <- function(fun, loud=FALSE) { | |
assign(fun, TRUE, envir=tracked) | |
calls <- 0 | |
countedFun <- function(...) { | |
calls <<- .Primitive('+')(1, calls) | |
if (loud) | |
cat('call made to:', fun, '\n') | |
.Primitive(fun)(...) |
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 <- list(id=242, 'session_id'='ah876fh3', main='page.html') | |
makeURL <- | |
# Given a named list of key/values, concatenate to make a URL. The | |
# value of the entry with key 'main' is treated as the HTML page. | |
function(pieces) { | |
m <- which(names(pieces) == 'main') | |
keys.values <- paste(names(pieces[-m]), pieces[-m], collapse='&', sep='=') | |
return(paste(pieces[[m]], keys.values, sep='?')) | |
} |
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
d <- local({ | |
s <- apply(obj$qual.freqs[, -1], 1, binsample) | |
tmp <- t(s) | |
nr <- nrow(tmp) | |
dim(tmp) <- c(ncol(tmp)*nrow(tmp), 1) | |
tmp <- as.data.frame(cbind(1:nr, tmp)) | |
colnames(tmp) <- c('position', 'quality') | |
return(tmp) | |
}) |
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
# R package Makefile template | |
# Vince Buffalo <[email protected]> (with poly-A tail removed) | |
# | |
# Replace 'package' with the name of your package (which should be a | |
# directory). My layout for package development is: | |
# package_build | |
# - TODO | |
# - Readme.md (for Github) | |
# - package (actual R package directory) | |
# - Makefile (this) |
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 you have a long vector of integers to compare against an integer literal, | |
# specify that the numerical literal is an integer rather than letting | |
# R coerce the entire vector to doubles. | |
x <- as.integer(floor(rnorm(1000000, 0, 1000))) | |
system.time(x < 0) | |
# user system elapsed | |
# 0.014 0.000 0.014 | |
system.time(x < 0L) |
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
## Vince Buffalo's .profile | |
## Some fun first: | |
curl --connect-timeout 1 -Is slashdot.org | egrep '^X-(F|B)' | sed 's/^X-//' | |
## Set environmental variables | |
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin/:$PATH | |
export CLICOLOR=1 | |
export EDITOR="emacsclient" | |
export LSCOLORS="gxfxcxdxbxegedabagacad" |
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
shell -$SHELL | |
startup_message off | |
defscrollback 30000 | |
autodetach on | |
hardstatus on | |
hardstatus alwayslastline | |
altscreen on | |
screen -t irc 0 /opt/local/bin/irssi |
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
;; From Michael Hannon and Vince Buffalo | |
(require 'cl) | |
(defun flatten (list) ; From `misc-fns.el'. | |
"Flatten LIST, returning a list with the atoms in LIST at any level. | |
Also works for a consp whose cdr is non-nil. | |
Borrowed from: http://www.emacswiki.org/emacs/lib-requires. |
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
## analysis.R -- looking at how similar the results of edgeR and DESeq are | |
## [email protected] sans poly-A tail | |
library(pasilla) | |
library(DESeq) | |
library(edgeR) | |
library(ggplot2) | |
library(limma) |
OlderNewer