dat <- matrix(c( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 7, 2, 4, 0, 0, 0, 0, 1, 3, 4, 3, 5, 10, 4, 9, 2, 2, 1, 0, 1, 0, 1, 1, 3, 12, 18, 14, 7, 4, 3, 3, 0, 0, 1, 16, 4, 17, 27, 20, 33, 25, 20, 11, 4, 5, 1, 0, 7, 11, 16, 25, 31, 34, 48, 21, 18, 4, 3, 0, 0, 3, 5, 14, 15, 36, 38, 28, 38, 19, 11, 4, 0, 0, 0, 3, 3, 5, 2, 17, 17, 14, 13, 4, 0, 0, 0, 0, 1, 0, 9, 5, 7, 11, 11, 7, 7, 5, 2, 1, 0, 0, 1, 1, 4, 4, 1, 5, 5, 0, 2, 0, 0, 0, 0, 0, 1, 0, 2, 4, 1, 2, 2, 1, 1, 0, 0, 0, 0, 0), nrow=11,ncol=14,byrow=T) m1 <- apply(dat,1,sum) dat1 <- cbind(dat,m1) m2 <- apply(dat1,2,sum) dat12 <- rbind(dat1,m2) colnames(dat12)<-c("<61.7",seq(62.2,73.2,by=1),">73.7","Total") rownames(dat12)<-c(">73.0",seq(72.5,64.5,by=-1),"<64.0","Total") print(dat12) d <- as.vector(t(dat)) child.factor <- gl(14,1,154) parent.factor <- gl(11,14,154) child.height <- 60.2 + as.numeric(child.factor) parent.height <- 74.5 - as.numeric(parent.factor) child <- rep(child.height,d) parent <- rep(parent.height,d) child.parent <- lm(child ~ parent) parent.child <- lm(parent ~ child) plot(child.height,parent.height,type="n") text(child.height,parent.height,d) abline(child.parent) abline(parent.child) print(summary(child.parent)) print(summary(parent.child))