Instructions: This is an open book, open notes, and open Google/internet test. This is a closed phone and closed neighbor test. You may use R on your own computer. You may use a calculator.

Type your answers to the questions into an R Notebook. Answer the questions in order. Answer each the question that is asked above your R code chunks. You must write a sentence containing your answer.

Your files should have a name in the usual form for the class lastname_firstname_Stat651_Quiz.Rmd and lastname_firstname_Stat651_Quiz.docx. Submit both files in Backboard before the end of class period.

Academic Honesty: As a student at CSU East Bay you are held to the standards stated in the Academic Dishonesty Policy. Copying another student’s work or allowing another student to copy your work is academically dishonest. I expect you to be academically honest while taking the test.

These questions are related to the homework in Chapter 11 and 14.

Load the choroplethr and choropletherMaps packages.

library(pacman)
p_load( tidyverse, choroplethr, choroplethrMaps, rUnemploymentData )
data(df_state_age_2010)
data(df_state_age_2015)
  1. For the df_state_age_2010 and df_state_age_2015 data sets in the choroplethr R package, answer the following:

    1. What are the variable names in these data frames?
    2. Make state choropleth maps for the median age of people in each state, for 2010 and 2015, using the state_choropleth() function.
    3. Which states have the oldest populations in 2010? And in 2015?
  2. For the df_pop_state data set in the choroplethr R package, answer the following:

    1. Make a state choropleth map for the population of people in each state using the state_choropleth() function.
    2. Which states have the highest population?
  3. For the df_state_demographics data set in the choroplethr R package, answer the following:

    1. Make a state choropleth map for the per capita income in each state using the state_choropleth() function.
    2. Which states have the highest per capita income?
  4. Load the rUnemploymentData R package. Run the animated_county_unemployment_choropleth() function to create the maps. Find the animated_choropleth.html file and run the dynamic visualization. Answer the following:

    1. Between 1990 and 2013 has the SF Bay Area every had very high unemployement rates relative to the highest unemployment counties in the country?
    2. What is wrong with the scale used for the color used in the maps?
  5. Try the same visualizations in Tableau at home.

data(df_county_unemployment)

write_csv(df_county_unemployment, "df_county_unemployment.csv")

Suggestion: Before kitting your R Notebook you should comment out this code so that the pictures are not regenerated. It takes quite a while to generate the plots and longer during the knitting process. There is no output shown, so there is no reason to rerun it.

LS0tCnRpdGxlOiAiU3RhdC4gNjUxIFF1aXogMiIKYXV0aG9yOiAiUHJvZi4gRXJpYyBBL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