This file contains hidden or 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
## Performance tuning `rbind.fill` | |
```{r setup, include=FALSE, cache=FALSE} | |
library(methods) | |
opts_chunk$set(cache=TRUE, dev="svg", tidy=FALSE, | |
fig.width=5, fig.height=5, autodep=TRUE, | |
fig.path='figure-') | |
with_dir <- function(dir, expr) { | |
prev <- getwd() | |
setwd(dir) |
This file contains hidden or 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
library(plyr) | |
library(ggplot2) | |
library(R.cache) | |
library(rstan) | |
#There is a sensor which either emits "yes" or "no." It adds up | |
#signals over some region of space (The "receptive field", which we | |
#model as having a Gaussian profile,) and emits a "yes" if the | |
#summed-up spatially weighted signals, plus unit additive noise, are | |
#over some threshold. |
This file contains hidden or 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
library(ggplot2) | |
library(plyr) | |
theme_set(theme_bw()) | |
theme_update(panel.border=element_blank()) | |
# A reaction time experiment works as follows: On each trial, an | |
# observer is asked to view a stimulus and categorize it into one of | |
# multiple values. For instance, it may be a noisy motion stimulus, | |
# and the observer is asked to classify the motion as "leftward" or |
This file contains hidden or 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
# User facing function | |
# | |
# to_math(x_1 + 1^{2 + 4} + 5 + sqrt(y) / 5 %/% 10) | |
# to_math(paste(x^2, y - 1, z_i)) | |
# to_math(hat(tilde(ring(x)))) | |
# to_math(pi*r^2) | |
# to_math(unknown_call(x, floor(sqrt(z)))) | |
to_math <- function(x) { | |
x <- substitute(x) | |
env <- latex_env(x) |
This file contains hidden or 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
#.bash_profile | |
TIMEOUT=10 | |
function speak_if_long { | |
last_command_time=$(HISTTIMEFORMAT="%s " history 1 | awk '{print $2}') | |
if (( $(date -u +"%s") - $last_command_time > $TIMEOUT )) | |
then | |
say "I'm done" | |
fi | |
} |
This file contains hidden or 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
## | |
{ | |
## let's go ahead and generate the possibilities. | |
x <- 2 | |
y <- pi | |
z <- exp(1) | |
`%^%` <- `^` | |
`%/%` <- `/` |
This file contains hidden or 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 flymake support (if Flymake is available) This will call a script | |
;; "rflymake" with the path given; make sure it is on emac's exec-path | |
;; or give a full path. | |
(when (require 'flymake nil) | |
(defun flymake-r-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-temp-inplace)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) |
This file contains hidden or 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
#negative numbers for "symbol" will be interpreted as Unicode values. | |
#But you must use a fint that supprots the symbols you want. | |
dataset <- chain(1:16, expand.grid(x=., y=.), mutate(shape=seq_along(x))) | |
print(ggplot(dataset) + aes(x=x, y=y, shape=factor(shape)) | |
+ geom_point() | |
+ discrete_scale("shape", "manual", name="shape", palette=function(x) -seq(0x25A0L, length=x)) | |
+ theme(legend.position="none") | |
) |
This file contains hidden or 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
#!/bin/bash | |
set -v verbose | |
trap exit ERR | |
#I want to extract a number of submodules from a larger project. | |
#Also to preserve untracked files (e.g. lengthy data build products) | |
CWD=`pwd` | |
REPO_DIR="direction_discrimination_analysis" | |
SUBMODULES="mothballed_writing previous_draft newer_draft" |
This file contains hidden or 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
#put this in your ~/.bash_profile | |
# | |
#If a long-running command terminates, ring the bell and float the | |
#(OSX Terminal) window. | |
LONG_RUNNING=20 #how long is long? Enough for me to get bored and tab away. | |
function popup_if_long { | |
last_command_time=$(HISTTIMEFORMAT="%s " history 1 | awk '{print $2}') | |
if (( $(date -u +"%s") - $last_command_time > $LONG_RUNNING )) |