---
title: "SurveyAnalysisHomeworkExample"
author: "Kamala Harris"
date: "January 29, 2018"
output:
word_document: default
pdf_document: default
html_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## 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
```{r}
# First we'll clear the workspace and load in the survey data:
rm(list = ls())
survey <-
read.csv("http://www.courses.washington.edu/psy315/datasets/Psych315W21survey.csv")
# Then create the table
myTable <- table(survey$computer,survey$hand)
# The result is a table with both rows and columns, with labels:
myTable
# The labels can be pulled out using 'row.names' and 'colnames' (note
# the inconsistency using '.' in the function names)
row.names(myTable)
colnames(myTable)
# 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:
```{r}
# Here's the table of the results:
myTable
# And the bar graph:
barplot(myTable,
beside=TRUE,
legend = row.names(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.