Answered step by step
Verified Expert Solution
Link Copied!

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 1974.
```{r}
states %>% head()
```
Motivation:
We want to understand how income varied between regions of the US in a dataset from 1974. 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 %>% ggplot(aes(x=region, y=income, fill=abb))+
geom_col()+
geom_text(aes(label=abb,y=income),position=position_stack(vjust=0.5))
```
We will instead plot bar plots of (1) the total income vs. income from the most populous states (a grouped bar plot), and (2) the income of the most populous states (a stacked bar plot).
### a*. Create a table named income_by_region with four columns: total_income, which will have the sum of all income in the region; max_income, which will have the maximum state income for each region; median_income, 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

Explain the steps involved in training programmes.

Answered: 1 week ago

Question

What are the need and importance of training ?

Answered: 1 week ago

Question

What is job rotation ?

Answered: 1 week ago

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago