Lab 2E
Directions: Follow along with the slides, completing
the questions in blue on your
computer, and answering the questions in red in your
journal.
Space, Click, Right Arrow or swipe left to move to
the next slide.
data
function to load the slasher
data file.
Male
or
Female
.Dies
or
Survives
.format = "percent"
to
obtain a two-way table with percentages.## gender
## survival Female Male
## Dies 77.47748 86.69202
## Survives 22.52252 13.30798
## Total 100.00000 100.00000
survival
status to each observation. Compare the resulting
table to the one you wrote down.To help us decide if the difference in percentages in our
actual data occurs by chance or not, we can use the
do()
function to shuffle our data many times and see how
often our actual difference occurred by chance.
Run the following lines of code:
shuffled_outcomes <- do(10) * tally(~shuffle(survival) | gender,
format = "percent",
data = slasher)
(12) In how many simulations did a higher percentage of males survive than females?
(13) What is the largest difference in percentages of survival between males and females?
(14) What patterns are emerging from these simulations?
Ten simulations is not enough. Use the code
above and perform 500 shuffles. Assign
your 500 shuffles
the same name shuffled_outcomes
. Use
set.seed(1)
.
mutate
function.
Survives.Female
and
Survives.Male
to our shuffled_outcomes
data.histogram
of
the diff
erences in our shuffled_outcomes
data.
Based on your plot, answer the following:
gender
play a role in whether or not
a character will survive in a slasher film? Explain your
reasoning.survival
label, we made the proportion
of males and females who survived the slasher film random.
gender
variable instead of the
survival
variable.
set.seed(1)
before your 500
simulations to make your answer reproducible.gender
variable instead
of the survival
variable change your answer to the
question?survival
play a role in a character’s
gender
? Why or why not?