SurveyAnalysisHomeworkExample
Kamala Harris
January 29, 2018
Hypothesis: Does the choice of computer depend on handedness?
I want to test the hypothesis that whether students use Apple or PC’s varies with whether
your left or right handed. This is a comparison of nominal to nominal scale data, so it’ll
require making a bar plot of frequencies:
Analysis:
The following R code loads in the survey data and creates our 2x2 table of frequencies
# First we'll clear the workspace and load in the survey data:
rm(list = ls())
survey <-
[Link]("[Link]
[Link]")
# Then create the table
myTable <- table(survey$computer,survey$hand)
# The result is a table with both rows and columns, with labels:
myTable
##
## Left Right
## Apple 5 90
## Other 0 11
## PC 2 44
# The labels can be pulled out using '[Link]' and 'colnames' (note
# the inconsistency using '.' in the function names)
[Link](myTable)
## [1] "Apple" "Other" "PC"
colnames(myTable)
## [1] "Left" "Right"
# The first and third rows correspond to Apple and PC's, and the 1st
and 2nd columns
# correspond to left and right handedness. This pulls out the
relevant subset of rows and
# columns:
myTable <- myTable[c(1,3),c(1,2)]
Results:
# Here's the table of the results:
myTable
##
## Left Right
## Apple 5 90
## PC 2 44
# And the bar graph:
barplot(myTable,
beside=TRUE,
legend = [Link](myTable),
col = c("Red","Blue"))
Summary
Looking at the graph, it appears that the ratios of PC to Apple users is pretty much the same
across handedness. I therefore don’t think that there is a difference in the choice of
computers between left and right handers.