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 | |
`?` <- function(x, y) { | |
y <- substitute(y) | |
if (!is.call(y) || !identical(as.symbol(":"), y[[1]])) stop("Invalid", call. = FALSE) | |
eval(call("if", x, y[[2]], y[[3]])) | |
} | |
T ? 1 | |
#> Error: Invalid |
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
#!/bin/bash | |
############################ | |
# CONFIG: Change these as necessary | |
############################ | |
# pandoc | |
PANDOC_CMD="pandoc" | |
PANDOC_OPTS="-s --latex-engine=xelatex" | |
# latexmk |
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
#!/bin/bash | |
# | |
# Copy data from a Time Machine volume mounted on a Linux box. | |
# | |
# Usage: copy-from-time-machine.sh <source> <target> | |
# | |
# source: the source directory inside a time machine backup | |
# target: the target directory in which to copy the reconstructed | |
# directory trees. Created if it does not exists. | |
# |
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
data(PlantGrowth) | |
pg<-subset(PlantGrowth,group!='ctrl') | |
pg$group=factor(pg$group) | |
pg1= pg[pg$group=='trt1',] | |
pg2= pg[pg$group=='trt2',] | |
hist(pg$weight) | |
lines(density(pg1$weight), col='blue') | |
lines(density(pg2$weight), col='red') |
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
data(faithful) | |
attach(faithful) | |
#Assumes two gaussian populations of eruptions | |
W = waiting | |
# Guess of the parameters: | |
s = c(p=0.5, mu1=50, mu2=90, sigma1=30, sigma2=30) | |
# EXPECTATION STEP | |
expectation_step <- function(observed, parameters){ |