Answered step by step
Verified Expert Solution
Question
1 Approved Answer
### Intro. Run this to see what the states data frame looks like. This data frame contains statistics for different states in 1 9 7
### Intro. Run this to see what the states data frame looks like.
This data frame contains statistics for different states in
r
states head
Motivation:
We want to understand how income varied between regions of the US in a dataset from In this case, the income represents the total income for the population. We want to know whether some more populous states are driving the difference between incomes for the regions.
### Intro. Run this code to see a stacked bar plot of income by region for all the states.
You will notice that it is so busy that it's hard to read.
r
states ggplotaesxregion, yincome, fillabb
geomcol
geomtextaeslabelabb,yincomepositionpositionstackvjust
We will instead plot bar plots of the total income vs income from the most populous states a grouped bar plot and the income of the most populous states a stacked bar plot
### a Create a table named incomebyregion with four columns: totalincome, which will have the sum of all income in the region; maxincome, which will have the maximum state income for each region; medianincome, which will have the median state income for each region; and n the number of states in each region. Arrange this in descending order for the median income.
Hint: what command is implied by "for each"?
You will notice that the largest maximum income corresponds to the smallest median income. This finding makes us suspect that some states with larger populations could be contributing more to income in the region.
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