# 9-7 Tables

# The data is held in the files
#    ShopperPreferences.csv
#    Marmite.csv
# These are within the SP09 folder of the current working directory
# The files contain headers

# Load shopperprefs file

shopperprefs<-read.csv("SP09/ShopperPreferences.csv", header=TRUE)

# Display shopperprefs

shopperprefs

# Create a table (contingency table) for shopperprefs

table(shopperprefs)

# Load marmite file

marmite<-read.csv("SP09/Marmite.csv", header=TRUE)

# Display marmite

marmite

# Bind marmite to shopperprefs

shopperprefs<-cbind(shopperprefs,marmite)

# Display shopperprefs

shopperprefs

# Create a table (contingency table) for shopperprefs

table(shopperprefs)

# Create a table (contingency table) of chocolate vs. Marmite

table(list(shopperprefs$Chocolate,shopperprefs$Marmite))

# Create a set of tables for all columns of shopperprefs

table(shopperprefs)
