Question: In the plot we just made in Q6 we see high variability for low values of height. This is because we have few data points.
In the plot we just made in Q6 we see high variability for low values of height. This is because we have few data points. This time use the quantile 0.1,0.2,...,0.9
and the cut() function to assure each group has the same number of points. Note that for any numeric vector x, you can create groups based on quantiles like this: cut(x, quantile(x, seq(0, 1, 0.1)), include.lowest = TRUE).
Part of the code is provided here:
ps <- seq(0, 1, 0.1) heights %>% # MISSING CODE group_by(g) %>% summarize(p = mean(sex == "Male"), height = mean(height)) %>% qplot(height, p, data =.)
Which of the following lines of code can be used to replace # MISSING CODE to make the correct plot?
mutate(g = cut(male, quantile(height, ps), include.lowest = TRUE)) %>% mutate(g = cut(height, quantile(height, ps), include.lowest = TRUE)) %>% mutate(g = cut(female, quantile(height, ps), include.lowest = TRUE)) %>% mutate(g = cut(height, quantile(height, ps))) %>%
What's the answer please and why!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
