################################################### ### Q1 Data: ################################################### x <- 1:10 y <- as.factor(rep(c("A","B"), c(5,5))) ################################################### ### Q2 Data: ################################################### v <- rnorm(20) + 4 mean.8 <- rep(0, length(v) - 7) for (i in 1:length(mean.8)) mean.8[i] <- mean(v[i:(i+7)]) ################################################### ### Q3 Data: ################################################### temp <- matrix(runif(60, -4, 4) + 25, ncol=3) rowfun <- function(row) { row/sum(row)*100 } y <- t(apply(temp, 1, rowfun)) ################################################### ### Q4 Data: ################################################### propns <- list(sex=list(male=c(.79, .75)), race=list(black=c(0.01, 0.05), caucasian=c(0.95, 0.94), oriental=c(0.03, 0.01), other=c(0.01, 0)), smoking=c(0.38, 0.36))