Statistics 651: Homework


Final:

(due end of Finals week, Saturday December 13, end of the day)

Instructions: This is a take-home midterm. Your work is to be completed individually. You may use your book, google, and questions can be asked of the instructor through You are not to share computer code with others in the class.

Intructions: Follow the instructions in the Zipped R Projects below.

1) Visit the Data Is Beautiful YouTube channel and watch a few of the videos. These kinds of visualizations are quite popular these days. a) Describe in detail the different kinds visualizations that are present in the videos. b) Comment on what is wrong with the Most Popular Music Styles 1910 - 2019 video.

2) Read over Chapter 7 of the r4ds book. Do 7.5.1.1. Exercises 4 using the lv_plot and also using the violin plot. Compare your two new plots to using boxplots.

3) Make your own self Evauation check list. Review the best_practices.html presentation and make a one page check list for Evaluating your data visualizations for use in the future.


Quiz 2

(due in Blackboard Sunday November 29, 2020)


Homework 4:

Using an R Notebook produce your solutions to the following questions. Start by making an R Notebook with file name Lastname_Firstname_Stat651_hw4.Rmd. Then knit the .Rmd file to either Lastname_Firstname_Stat651_hw4.html. Use your own last name and first name in the filename. At the top of your first page you should include Name, Class, Section, and homework assignment.

The header of your R Notebooks should include

title: "Stat. 651 Homework 4"

author: "Your name"

date: "December 7, 2020"

Upload one file to Blackboard.

Problems:

  1. TBA

Project:

(due in Blackboard Friday December 11, 2020)

Make two statebins using data from GeoFRED. Use the socviz Chapter 7 Section 3 as a reference.

Complete your work in an R Notebook and turn in both a .Rmd and .pdf or .docx file using the usual filename. lastname_firstname_Stat651_Project.Rmd and lastname_firstname_Stat651_Project.docx.

Hint: The code from socviz is now out of date. The statebins R package has been updated to work with the tidyverse. See help("statebins").


Midterm

(due in Blackboard Friday December 4, 2020)

Instructions: This is a take-home midterm. Your work is to be completed individually. You may use your book, google, and questions can be asked of the instructor through You are not to share computer code with others in the class.

Intructions: Follow the instructions in the Zipped R Projects below.

Updated Instructions: In one folder Lastname_Firstname_Stat651_01_Midterm create separate R projects for each parter of each question. Each Project should have a directory name such as Problem_01_heatmap, Problem_02_example, Problem_02_replaced_data, and Problem_03_flexdashboard. Please do not download all of the Lyft BayWheels data, you should only include the data you use in your dashboard.

1) Find an example of a Shiny App that uses a heatmap. Download the code and get it to work.

2) Download the Shiny App that plots the Google Trend Index for five topics. The App is at the bottom or the RStudio Shiny webpage. Here is the github link Google Trend Index App. Get the code to work. Change the topics to other related topics of interest to you. Turn in two R Projects, the original one and the new one that has at least two different topics.

Hint: Try out Google Trends US if you are not familiar with it.

Hint: To get the Google Trends Index App to work you should start an R Project by clicking on Projects > New Project on the RIGHT and select single file App. You will need to go to the authors GitHub and download the two data files. Save the two files into a subdirectory data in the R Project directory.

More directions: Now that you have the App running you need to figure out how to replace the data in the two files with different data. You can change the trend_description.csv directly. I would suggest listing two topics. Then replace the data. There is an R package gtrendsR. Install it and try some code like what follows. Run the code in your R Project so the trend_data.csv file is replaced in the subdirectory /data. Here is what it should look like Google-Trends-Shiny-App

library(tidyverse)

library(gtrendsR)

data("categories")

head(categories)

res <- gtrends(c("golf","football"), geo = c("US"), time = "all")

plot(res)

res <- res$interest_over_time

head(res)

res %>% select(keyword, date, hits) %>%

rename(type = keyword, close = hits) %>%

write_csv("data/trend_data.csv")

3) Make a flexdashboard for the Lift BayWheels.

To get the updated Lyft BayWheels, here is the link to the data use the same code you used in Stat. 650. Here is the link to the website with the code we used. The East Bay R Language Beginners Group

To start use the data from the most recent month available.

You should use the code in the fordgobike01.Rmd, as we used before, to download the updated data. Or your own code.

(Optional, not recommended) If you are interested in directly connecting to the gbfs API, try out the code infordgobike02.Rmd, which pull information about the stations, not individual rides. (That is my understanding so far.)

I would like you to make a dashboard using the flexdashboard R package. To do this you can use the code you developed before, make some visualizations similar to the ones I have included, and put them into a dashaboard.

Including visualizations of monthly users and yearly users would be good.

Explain: Write a statement about what your dashboard is trying to communicate.


Quiz 1

(due in Blackboard Sunday November 15, 2020)


Homework 3:

(due Monday November 30, 2020)

Special Intructions: Put all of your R code, .docx, .html, etc. files, and Tableau files into your R Project folder. See the Zipped R Project guidelines above.

Using an R Notebook produce your solutions to the following questions. Start by making an R Notebook with file name Lastname_Firstname_Stat651_hw3.Rmd. Then knit the .Rmd file to either Lastname_Firstname_Stat651_hw3.html. Use your own last name and first name in the filename. At the top of your first page you should include Name, Class, Section, and homework assignment.

The header of your R Notebooks should include

title: "Stat. 651 Homework 3"

author: "Your name"

date: "November 16, 2020"

Upload one file to Blackboard.

Problems:

  1. Chapter 11 Exercise 11.9
  2. Make the plot from Exercise 11.9 in Tableau
  3. Chapter 14 Exercises 14.2, 14.4 (I have added this problem. It would be best to make a plot using ggplot first.), 14.5 ( use tidygeocoder, leaflet and sf ), 14.6 (use tigris and sf)
  4. Watch the Upping Your Data Viz Game

Hint: For 2. Read this blog post. Got a Scatter Plot? Learn How to Add Marginal Histograms See Week 5 for the data file HELPrct.csv.

Hint: For 3. Exercise 14.2 Here is the link to some maps MacLeish Field Station maps. Here is the link to the readme.

Hint: For 3. Exercise 14.5 To install ggmap you should follow the installation procedure on the author's github. ggmap github

The main step is: When you load ggmap, you can set your API key with register_google() (see ?register_google for details), but don’t forget to enable the Maps Static API in the Google Cloud interface and enable billing!

Update: Start by geocoding the unique addesses and zipcode. Use the tidygeocoder R package. Think about how many popup might be reasonable to display before geocoding all of the address. Maybe start with 10 and increase to a reasonable number. It takes some time to download when geocoding. Then remove na's using the drop_na() function. Take a sample of 50 and make the plot. Plot points only in NYC, so filter out anything that has been geocoded incorectly. See Week 5 for the data file Violations_loc.csv. This file contains my geocoded location data.

Hint: For 3. Exercise 14.6 Read the R Journal paper tigris

You can install the fec package from the author's github.

devtools::install_github("beanumber/fec")

Be sure to say NO to updating any of your packages.

Update: The new version of the tigris R package use sf.

Here is a nice presentation that describes using tigris.

And you might want to use the glue R package.


Zipped R Projects

Here is a document and an example zipped R Project file. When turning in hw and other assignments you should follow these guidelines.

It should be clear that firstname and lastname are your names. So you need to fill in your names in place of firstname and lastname.

Also it should be clear that .zip is a zipped file. Other compression methods are not what I am talking about. Your zipped file should have a .zip at the end.


Homework 2:

(due November 2, 2020)

Special Intructions: Put all of your R code, .docx, .html, etc. files, and Tableau files into your R Project folder. See the Zipped R Project guidelines above.

Using an R Notebook produce your solutions to the following questions. Start by making an R Project and an R Notebook with file name Lastname_Firstname_Stat651_hw2.Rmd. Then knit the .Rmd file to either Lastname_Firstname_Stat651_hw2.html. Use your own last name and first name in the filename. At the top of your first page you should include Name, Class, Section, and homework assignment.

The header of your R Notebooks should include

title: "Stat. 651 Homework 2"

author: "Your name"

date: "November 2, 2020"

For the Tableau plots, export them to a .pptx file and submit them.

Problems:

  1. Watch the The beauty of data visualization - David McCandless
  2. Make the plots for the CIACountries data in Tableau. See Week 1 for the code for the CIACountries. ggplot2.Rmd
  3. Chapter 11 Exercises 11.1, 11.2, 11.3, 11.4, 11.5, 11.6

Hint: For 3. Exercise 11.6 The basic part of a Shiny app vegalite


Homework 1:

(due Monday October 19, 2020)

Using an R Notebook produce your solutions to the following questions. Start by making an R Notebook with file name Lastname_Firstname_Stat651_hw1.Rmd. Then knit the .Rmd file to either Lastname_Firstname_Stat651_hw1.docx or a .pdf file. Use your own last name and first name in the filename. At the top of your first page you should include Name, Class, Section, and homework assignment.

The header of your R Notebooks should include

title: "Stat. 651 Homework 1"

author: "Your name"

date: " October 19, 2020"

Upload your .docx or .pdf file and your .Rmd file to Blackboard.

Problems:

  1. Watch the TED The best Hans Rosling talks you’ve ever seen
  2. Chapter 3 Exercises 3.8, 3.9, 3.10