Answered step by step
Verified Expert Solution
Question
1 Approved Answer
### c . Create a table by merging the prior two tables, then melting to convert to long form. Don't change this code - just
### c Create a table by merging the prior two tables, then melting to convert to long form.
Don't change this code just run it
r
incomebyregiongroupedwide mergeincomebyregion selectregion totalincometopbypopulation,on"region"
incomebyregiongroupedlong meltincomebyregiongroupedwide,variable.name "incomecategory",value.name "income",idvars "region"
incomebyregiongroupedlong
### d Create a grouped bar plot from the incomebyregiongroupedlong data to allow us to compare the total and top states income in each region.
Each region should have two bars in different colors one color for totalincome, and one color for topincome.
Customize the plot by adding titlelabels adding a theme, and enlarging the font see Q; you can reuse the largerfont variable, if you wish
After completing the steps above, improve the plot as follows:
Instead of using xregion use xfctreorderregionincomecategory,income Notice how the regions are now ordered by the length of one of the bars.
Make the legend have a better title. You can do this inside the labs command where you set the x label, y label, and title. Here you can use fill to title the legend.
Customize the colors by adding onto the plot a line of code like this choose your own favorite color scheme!: scalefillmanuallabelscfull region","most populated states"valuescgray"slateblue"
r
### e Create a stacked bar plot of income by region for the top most populous states.
Hint: code needed for full row for top by population ggplot...
Encode the states using the fill color.
Add title, labels, a theme, and enlarged font.
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