pdf("ex0109.pdf") # Read in data from ASCII formatted (Fixed With File) ex0109dat <- read.fwf("http://www.stat.ufl.edu/~winner/data/biostat/ex0109.dat", width=c(8,8), col.names=c("wine","death")) # Create a dataset (frame) from input data ex0109 <- data.frame(ex0109dat) # Attach the dataset for analysis attach(ex0109) # Obtain crosstabulation of wine drinking and death freqwndth <- table(wine, death) freqwndth # Obtain the proportions in each cell of table propwndth <- freqwndth/sum(freqwndth) propwndth # Obtain the marginal frequencies and Proportions for wine (rows=1st dimension) winefreq <- margin.table(freqwndth,1) wineprop <- winefreq/sum(freqwndth) winefreq wineprop # Obtain the marginal frequencies and Proportions for death (columns=2nd dimension) deathfreq <- margin.table(freqwndth,2) deathprop <- deathfreq/sum(freqwndth) deathfreq deathprop dev.off()