# Topic 12 How Faithful is Old Faithful? # R commands for Question 4. data=read.table("http://bayes.bgsu.edu/m400/data/oldfaith.txt", header=T,sep="\t") attach(data) # Part (a) # creates a categorical variable for eruption length DurLCat=cut(DurLast,c(0,2.5,Inf),c("short","long")) # finds descriptive statistics for short and long eruptions summary(DurLast[DurLCat=="short"]) summary(DurLast[DurLCat=="long"]) # Part (b) # compare the waiting times for short and long eruptions boxplot(WaitNext~DurLCat,ylab="Waiting Time") # Part (c) # creates a categorical variable for waiting time WaitNCat=cut(WaitNext,c(0,65,Inf),c("short","long")) summary(WaitNext[WaitNCat=="short"]) summary(WaitNext[WaitNCat=="long"]) # Part (d) # creates a cross tabulation of two categorical variables crosstab=table(DurLCat, WaitNCat) # Part (e) # are eruption length and waiting time independent? chisq.test(crosstab)