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
library(diagram) | |
openplotmat(main="Flowchart for R Bug Reporting") | |
curvedarrow(from = c(0.5,0.85), to = c(0.8,0.725), curve = -0.2, arr.pos = 0.6) | |
curvedarrow(from = c(0.8,0.725), to = c(0.85,0.5), curve = -0.2, arr.pos = 0.5) | |
curvedarrow(from = c(0.85,0.5), to = c(0.8,0.26), curve = -0.2, arr.pos = 0.5) | |
curvedarrow(from = c(0.8,0.26), to = c(0.5,0.15), curve = -0.2, arr.pos = 0.53) | |
curvedarrow(from = c(0.5,0.15), to = c(0.2,0.3), curve = -0.2, arr.pos = 0.4) | |
curvedarrow(from = c(0.2,0.3), to = c(0.15,0.5), curve = -0.2, arr.pos = 0.5) |
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
# Simulation study for sample size between/within | |
# got Treat + Sham between subjects | |
# got Time within subjects | |
nPerGroup <- 30 | |
nTime <- 4 | |
muTreat <- c(37, 32, 20, 15) | |
muSham <- c(37, 32, 25, 22) | |
stdevs <- c(12, 10, 8, 6) | |
stdiff <- 9 |
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
# The Equation of Time | |
# based on trigonometric approximation on Wikipedia | |
equoftime <- function(M){ | |
-7.657*sin(M) + 9.862*sin(2*M + 3.599) | |
} | |
x <- equoftime((1:365)*2*pi/365.242) | |
y <- ts(x, start = 4, frequency = 365) | |
# set up the plot |
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
# Condorcet | |
Votes <- read.csv("Votes.csv") | |
candidates <- names(Votes) | |
nvoters <- dim(Votes)[1] | |
ncand <- dim(Votes)[2] | |
allpairs <- combn(1:ncand, 2) |
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
limsup <- function(x){ | |
z = rep(0,length(x)) | |
for(i in 1:length(x)){ | |
z[i] = max(x[i:length(x)]) | |
} | |
return(z) | |
} | |
set.seed(2) |
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
SLLN <- function( iter = 10, | |
p = 0.5){ | |
require(TeachingDemos) | |
x <- rbinom( iter, size=1, prob = p) | |
plot( cumsum(x)/1:length(x), | |
type="l", | |
#lwd = 2, | |
ylab = "Relative Frequency", | |
xlab = "Cumulative Trials", |
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
#################################################################### | |
# WLLN | |
samp.size <- 5 | |
mu <- 10 | |
sigma <- 3 | |
histN <- 1000 |
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
# source: http://www.aul.org/2015/06/aul-releases-the-new-leviathan-the-mega-centers-report-how-planned-parenthood-has-become-abortion-inc/ | |
plot(x = c(74, 74, 774, 774), | |
y = c(-541, -213, -305, -572), | |
main = "PLANNED PARENTHOOD FEDERATION OF AMERICA:", | |
xlab = "", ylab = "", asp = 1, axes = FALSE, | |
xlim = c(74, 774), ylim = c(-679, -150), | |
type = "n") | |
mtext("ABORTIONS UP - LIFE SAVING PROCEDURES DOWN", side = 3) | |
arrows(x0 = 74, y0 = -541, x1 = 774, y1 = -305, | |
lwd = 3, 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
library(plyr) | |
library(qcc) | |
data("pistonrings") | |
attach(pistonrings) | |
x <- qcc.groups(diameter, sample) | |
detach(pistonrings) | |
find_zones <- function(x) { |