## Exercise 2
# Plot length of stay as a histogram
hist(data$los)
# Describe length of stay
library(psych)
losDes <- describe(data$los)
losClusDes <- describeBy(data$los, group=data$Cluster)
losClusDes[1]
losClusDes[2]
losClusDes[[1]][1]
losClusDes[[2]][4]
# Subset the data by cluster
clusSeven <- subset(data, data$Cluster == 7)
clusEight <- subset(data, data$Cluster == 8)
clusNA <- subset(data, is.na(data$Cluster))
# Plot the cluster length of stays as histograms
hist(clusSeven$los)
hist(clusEight$los)
hist(clusNA$los)
# Conduct t-tests on the cluster length of stays
t.test(clusSeven$los,clusEight$los)
t.test(clusSeven$los,clusNA$los)
t.test(clusEight$los,clusNA$los)
# Plot the cluster length of stays as a box plot
boxplot(clusSeven$los,clusEight$los,clusNA$los, outline=FALSE)