Lab 2D
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.
"rap"
songs, 23
"country"
songs and 47 "rock"
songs.
c
ombined
playlist the name songs
.0.30
.replace
option in the sample
function to
FALSE
.size
100 from our playlist of songs without replacement. Assign this
sample the name without
.
tally(without)
and describe the
output.~
was not needed with the
tally
function. This is because without
was
not a variable within a data frame but rather a vector which acts like a
lone variable.size = 101
and
replace = FALSE
?sample
from the candy jar. Assume the simulated jar is
named candies
.do
function
to perform 10 simulated sample
s of size
2,
without replacement and assign the simulations the name
draws
and then View
your file. Use
set.seed(1)
."rap"
songs.(14) Write and run code performing 500 simulations of
sampling 2 songs from a playlist of 30 "rap"
, 23
"country"
and 47 "rock"
songs. You might
consider running set.seed
so that your results can be
reproduced:
(15) Calculate and write down the estimated probabilities for the following situations:
"rap"
songs."rap"
song in the first draw and a
"country"
song in the 2nd.(16) Create a histogram
that displays the
number of times a "rap"
song occurred in each simulation.
How often were zero rap songs drawn? A single rap song? Two rap
songs?
(17) If we draw 5 songs from a playlist of 30 rap, 23 country and 47 rock songs, how does the estimated probability of all 5 songs being rap songs change if we draw the songs with or without replacement?
histogram
for the number of
rap songs that occurred for each of the 500
repetitions.