Lab 2E
Directions: Follow along with the slides and answer the questions in red font in your journal.
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.do()
function to shuffle our data many times and see how often our actual difference occurred by chance.Run the following lines of code:
In how many simulations did a higher percentage of males survive than females?
What is the largest difference in percentages of survival between males and females?
What patterns are emerging from these simulations?
Ten simulations is not enough. Use do
, tally
and shuffle
functions to shuffle
the survival
variable and tally
the percentage of women who survived 500 times. Assign
your 500 shuffles the name shuffled_survivors
. Use set.seed(1)
mutate
function.
Survives.Female
and Survives.Male
to our shuffled_survivors
data.Create a histogram
of the difference
s in our shuffled_survivors
data. Based on your plot, answer the following:
Include a vertical line in your histogram of the actual difference by running the code below:
gender
play a role in whether or not a character will survive in a horror film? Explain your reasoning.survival
label, we made it so that the proportion of males and females who survived the slasher film was 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 Does gender
play a role in whether or not a character will survive in a horror film?