rm(list=ls()) #clears memory setwd("/rstuff") #sets path x <- 1:5000 #number of iterations for "for" hnull <- NULL #creates null set dif2 <- NULL dif4 <- NULL #generate null distribution for(i in seq(along=x)) {hnull<-c(hnull, (mean(runif(25,1,10)))-(mean(runif(25,1,10))))} #randomly draws 100 continuous numbers #from 1 to 10, and calculates the mean #a2 <- sample(1:10, 500, replace=T) would draw 500 discrete observations #replace=T specifies sampling with replacement; replace=F is without replacement hnulls<-hnull/sd(hnull) #generate alternate distribution where means differ by 2 for(i in seq(along=x)) {dif2<-c(dif2, (mean(runif(25,3,12)))-(mean(runif(25,1,10))))} dif2s<-dif2/sd(dif2) #generate alternate distribution where means differ by 4 for(i in seq(along=x)) {dif4<-c(dif4, (mean(runif(25,5,14)))-(mean(runif(25,1,10))))} dif4s<-dif4/sd(dif4) beta <- cbind(hnulls,dif2s,dif4s) write.csv(beta, file = "beta.csv")