rm(list=ls()) #clears memory setwd("/rstuff") #sets path colif <- rnorm(25, mean=173, sd=20) # 25 random draws from a normal distribution fish <- rnorm(15, mean=3.3, sd=1) colifs<-c(colif, rep(NA,40-length(colif))) #fills to 40 with NA to match columns for cbind with max column length fishs<-c(fish, rep(NA,40-length(fish))) bgoose <- round(rnorm(40, mean=3.8, sd=.4), digits=0) agoose <- round(rnorm(35, mean=3.2, sd=.3), digits=0) #rounds to number of decimal places specified by 'digits=' agooses<-c(agoose, rep(NA,40-length(agoose))) #fills to 40 with NA to match columns for cbind tern <- ((rt(25, df=24))*0.23)+1.4 #converts standardized deviates from t- distribution #to observations by multiplying by s and adding mean avoc <- ((rt(18, df=17))*.1)+0.6 terns<-c(tern, rep(NA,40-length(tern))) avocs<-c(avoc, rep(NA,40-length(avoc))) a <- 1:10 #specifies observation number for "post" Daphcafpost <- NULL Daphconpost <- NULL Daphcafpre<-rnorm(10, mean=380, sd=20) #10 random draws from normal population Daphcafpost<-c(Daphcafpost, Daphcafpre[a]+rnorm(10, mean=40, sd=5)) #repeated measures example effect added to pre from normal mean of 40 #if the 'n' parameter for rnorm is 1 instead of 10 the result #of only a single draw will be added to each obs for Daphcafpre Daphconpre<-rnorm(10, mean=390, sd=25) Daphconpost<-c(Daphconpost, Daphconpre[a]+rnorm(10, mean=0, sd=2)) Daphcafposts<-c(Daphcafpost, rep(NA,40-length(Daphcafpost))) Daphcafpres<-c(Daphcafpre, rep(NA,40-length(Daphcafpre))) Daphconposts<-c(Daphconpost, rep(NA,40-length(Daphconpost))) Daphconpres<-c(Daphconpre, rep(NA,40-length(Daphconpre))) texam<-cbind(colifs,fishs,bgoose,agooses,terns,avocs,Daphcafposts,Daphcafpres,Daphconposts, Daphconpres) write.csv(texam, file = "texam.csv")