Answered step by step
Verified Expert Solution
Question
1 Approved Answer
We want to generate a plot of US arrest data (USArrests). Please provide the detailed codes to answer the following questions using R. a. Obtain
We want to generate a plot of US arrest data (USArrests). Please provide the detailed codes to answer the following questions using R.
a. Obtain USA state boundary coordinates data for USA map using function map data() and store the data in mdat. Display first few data from mdat and notice that there is a column called order that contains the true order of coordinates b. You will find USA crime data in the data frame called USArrests. Standardize the crime rates and create a new column called state so that all the state names are lower case. Store the new data in an object called arrest and report first few rows of arrest c. Merge the two data sets mdat and arrest by state name. Merging will change the order of coordinates data. So, order the data back to the original order and store the merged-ordered data in odat. Report first few data from odat d. All the columns of odat is not necessary for our analysis. So, subset by selecting only columns long, lat, group, region, Murder, Assault, UrbanPop, Rape. Store the data in sdat and report first few rows e. Melt the data frame sdat with id variables long, lat, group, region. Store the molten data in msdat and report first few rows of data f. The molten data frame msdat is now ready to be plotted. Create a plot showing USA state map, fill with value and facet_wrap with variable. Please don't add any legend and make sure that faceting labels are identified so that we can compare the facetted plots. g. Now examine the plot you have generated in question (f) and answer the following questions based on what you see in the plot i. For each of the crimes, name two states with the highest crime rate. ii. Do you think larger urban population is an indicative of larger murder rate? Why or why not? happen if we would not do this would happen if we would not order. h. In question (3b) we standardized the crime rates. Why do you think we did this? Explain what would i. In question (3c) we ordered the data after merging. Why do you think we have to order? Explain what a. Obtain USA state boundary coordinates data for USA map using function map data() and store the data in mdat. Display first few data from mdat and notice that there is a column called order that contains the true order of coordinates b. You will find USA crime data in the data frame called USArrests. Standardize the crime rates and create a new column called state so that all the state names are lower case. Store the new data in an object called arrest and report first few rows of arrest c. Merge the two data sets mdat and arrest by state name. Merging will change the order of coordinates data. So, order the data back to the original order and store the merged-ordered data in odat. Report first few data from odat d. All the columns of odat is not necessary for our analysis. So, subset by selecting only columns long, lat, group, region, Murder, Assault, UrbanPop, Rape. Store the data in sdat and report first few rows e. Melt the data frame sdat with id variables long, lat, group, region. Store the molten data in msdat and report first few rows of data f. The molten data frame msdat is now ready to be plotted. Create a plot showing USA state map, fill with value and facet_wrap with variable. Please don't add any legend and make sure that faceting labels are identified so that we can compare the facetted plots. g. Now examine the plot you have generated in question (f) and answer the following questions based on what you see in the plot i. For each of the crimes, name two states with the highest crime rate. ii. Do you think larger urban population is an indicative of larger murder rate? Why or why not? happen if we would not do this would happen if we would not order. h. In question (3b) we standardized the crime rates. Why do you think we did this? Explain what would i. In question (3c) we ordered the data after merging. Why do you think we have to order? Explain what
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