Lab 2F
Directions: Follow along with the slides and answer the questions in red font in your journal.
do
-loop and the shuffle
function, we could simulate randomly shuffling our data many times.
Is there any evidence to suggest that those who survived paid a higher fare than those who died?
fare
for their ticket.data
function to load the titanic
passenger and survival data.fare
s paid by passengers and facet the plot based on whether the passenger survived or not.
do
and the shuffle
functions to shuffle the passenger’s survival status 500 times.
median
fare paid.Assign
your shuffled data the name shuffled_survival
.Is there any evidence to suggest that those who survived paid a higher fare than those who died?
What about if instead of calculating the median fare price for each group after a shuffle, we calculated the mean fare price and took the difference (mean_survivor – mean_victim).
If we did this 500 times, what do you predict the distribution of differences will look like?
Use the do
and the shuffle
functions to shuffle the passenger’s survival status 500 times.
mutate
function to create a variable called diff
which is the mean fare of survivors minus the mean fare of non-survivors.What does the shuffled data reveal? Does the answer to the research question below change when using the mean fares instead of the median fares?
Is there any evidence to suggest that those who survived paid a higher fare than those who died?