# set working directory
setwd(“C:/Users/znolan/Dropbox/teaching/buad476/Projects/beer”)
# read data
treadmill.df <- read.csv("treadmillusers.csv")
# reformat categorical (factor) variables
treadmill.df$purchase.cat <- factor(treadmill.df$purchase.cat,levels=c("Basic","HighEnd"))
treadmill.df$gender.cat <- factor(treadmill.df$gender.cat,levels=c("Male","Female"))
treadmill.df$age.cat <- factor(treadmill.df$age.cat,levels=c("Teens","EarlyTwenties","LateTwenties","EarlyThirties","LateThirties","Fourties"))
treadmill.df$education.cat <- factor(treadmill.df$education.cat,levels=c("HighSchool","SomeCollege","Bachelors","PostBach"))
treadmill.df$maritalstatus.cat <- factor(treadmill.df$maritalstatus.cat,levels=c("Single","Partnered"))
treadmill.df$usage.cat <- factor(treadmill.df$usage.cat,levels=c("Two","Three","Four","Five","Six","Seven"))
treadmill.df$fitness.cat <- factor(treadmill.df$fitness.cat,levels=c("Poor","Okay","Average","Good","Excellent"))
treadmill.df$income.cat <- factor(treadmill.df$income.cat,levels=c("<40k","40-60k","60-80k","80k+"))
treadmill.df$miles.cat <- factor(treadmill.df$miles.cat,levels=c("<50","51-80","81-110","111-140","141-170","171+"))
# segment inspection function
seg.summ <- function(data, groups) {
mean.table <- aggregate(data, by=list(groups),
FUN = function(x) mean(as.numeric(x)))
cat("\nMean Demographic Level by Segment:\n")
print(cbind(table(groups),mean.table[,-1]))
}
#######
## 1 ##
#######
#######
## 2 ##
#######
#######
## 3 ##
#######
#######
## 4 ##
#######
#######
## 5 ##
#######
#######
## 6 ##
#######
#######
## 7 ##
#######