Question: Hi dear tutor please help. this a Rstudio assignment Exercise 1. You will be working with a data set on painted turtles [species Chorsemys picto
Hi dear tutor please help. this a Rstudio assignment


Exercise 1. You will be working with a data set on painted turtles [species Chorsemys picto marginoto). [f you are interested. you can see more information about this species hie, although it is not necessary for success on this exercise. This data set includes measurements of the carapace [upper dorsal section, or shell] length, height, and width for male and female turtles. For several observations, the gender is unknown. [have provided a .csv file. FinaiimmTurtieDntocsv. on DZL. This data set originated from the Fimy R package, however. it has been modied to include several additional observations. a] Load the data set into RStudio. Perform your usual checks to make sure the data has been properly loaded and the variables are treated as the correct data type. Make any corrections if necessary. b} Next, you should split the data set into two separate data frames- One data frame will contain the observations where Gender is given. The other data frame should contain the two observations where (lender is missing. Hint: Your indexing skills might be useful for this step. c] Provide summaries of each of the carapace measurements for the data set where Gender is known, separated by Male and Female [i.e.. Get two sets of summaries. One for males and one for females]. These summaries should be included in your PDF/Word report. Hint: Your indexing skills may also be useful for this step. d} Create two histograms of your choice of carapace measurements. Make sure to include appropriate titles and axis labels. You may use base Rgraphics or ggpiotZ. Include the histograms in your PDF/Word report e] Create a scatterplot of your choice of carapace measurements. Color the points by Gender. Make sure to include appropriate titles and axis labels. You may use base R graphics or ggpioti'. Include the scatterplot in your PDF/'Word report. f]: Based on your scatterplot and your summaries of male and female turtles. can you make any guesses on the gender for your two unknown observations? Please continue to the next page. g) Fit a logistic regression model using the data set where Gender is known (not missing). Use Gender as the response variable (dependent variable) and Length, Width, and Height as predictors (independent variables). Provide the model summary in your PDF/Word report. Hint: We worked with logistic regression models in Week 5 if you need to review. h) Using the predict() function, get the predicted probability that Gender is Male. Report your predicted probabilities in your PDF/Word report. Hint: Arguments to the predict() function should be: object (your fitted logistic regression model), newdata (your unknown Gender data set), and type="response". This should return a vector of two probabilities (values between 0 and 1) that Gender is Male. i) Based on the rule "probabilities greater than or equal to 0.5 predict Male, and probabilities less than 0.5 predict Female", what are the predicted genders of your two unknown observations? Does this match up with what you guessed in part f)? Report your answer in your PDF/Word. Hint: no code is necessary for this step. Exercise 2. Write a function that takes one input argument, radius. This function should calculate (and return) the area of a circle with given radius if radius is greater than or equal to zero, or print an error message if radius is not greater than or equal to zero. Hint: Recall the formula for the area, A, of a circle with radius r: A = mr2. Also recall that R has a defined value for n, called pi. Finally, don't forget to document your function, and test it with several different values! Exercise 3. Write a for-loop that loops over integer values of i from 0 to 100, and calculates the area of a circle with radius defined by i. You may print or store the calculated areas. Hint: You may wish to use your function from Exercise 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
