pdf("ex0602.pdf") # Read in data from ASCII formatted (Fixed With File) ex0602dat <- read.fwf("http://www.stat.ufl.edu/~winner/data/biostat/ex0602.dat", width=c(8,8,8,8), col.names=c("trt","wtgain","tb","thal")) # Make trt a qualitative factor and assign names to levels treatment <- factor(ex0602dat$trt,levels=1:4) levels(treatment) = c("tbth","notbth","tbnoth","notbnoth") # Create a dataset (frame) from input data ex0602 <- data.frame(ex0602dat, treatment) # Attach the dataset for analysis attach(ex0602) # Conduct the One-Way ANOVA comparing weight gain by treatment using the nonparametric Kruskal-Wallis test # wtgain is the dependent variable, trt is independent variable kruskal.test(wtgain~treatment) dev.off()