Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Problem 3 We start from making the population in discussion material: {r} set.seed(2023) male = data.frame( length = rnorm (n=2000, mean =57.5, sd =3)
\# Problem 3 We start from making the population in discussion material: {r} set.seed(2023) male = data.frame( length = rnorm (n=2000, mean =57.5, sd =3) sex = rep ("Male",2000) female = data.frame ( length = rnorm (n=3000, mean =50.5,sd=2.8) sex = rep("Female", 3000) population_2 = bind_rows(male, female) {r} p1 > ggplot(aes( length)) + geom_histogram()+ geom_vline (aes( xintercept = mean ( population_2 $ length )) ) 2\. The code below generate the stacked histogram. Use 'ggarange' to show both plots in 1 plot, and give it suitable titles. {r} tr.:kable(population_2 1> group_by(sex) > summarise(average = mean(length), sd =sd( length))) (Hint: Think about the following code, and write similar things in 'mutate' for the 'sex') {r} string_vector =c("a","a","b") (string_vector =="a")5/6+( string_vector =="b")1/6 [1] 0.83333330.83333330.1666667 5\. Now we draw 300 samples without replacement** with the given weight. (Hint: ' 1> sample_n ( size = ?, replace = ?, weight = ?)') the result in the 'result_mean' and 'result_female_count' vectors and make a dataframe. (300(3000)/(2000+3000)). Use 'ggarange' to put it in one single plot. Use suitable title, axis label, themes, etc
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started