Lab 2F
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.
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?
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.shuffled_survival
.mutate
function to create a variable called
diff
which is the median
fare of survivors
minus the median
fare of non-survivors.
shuffled_survival
again.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 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?