Mini Data-Analysis Deliverable 1

Welcome to your (maybe) first-ever data analysis project!

And hopefully the first of many. Let’s get started:

  1. Install the datateachr package by typing the following into your R terminal:
install.packages("devtools")
devtools::install_github("UBC-MDS/datateachr")
  1. Load the packages below.
library(datateachr)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
  1. Make a repository in the https://github.com/stat545ubc-2023 Organization. You can do this by following the steps found on canvas in the entry called MDA: Create a repository. One completed, your repository should automatically be listed as part of the stat545ubc-2023 Organization.

Instructions

For Both Milestones

  • Each milestone has explicit tasks. Tasks that are more challenging will often be allocated more points.

  • Each milestone will be also graded for reproducibility, cleanliness, and coherence of the overall Github submission.

  • While the two milestones will be submitted as independent deliverables, the analysis itself is a continuum - think of it as two chapters to a story. Each chapter, or in this case, portion of your analysis, should be easily followed through by someone unfamiliar with the content. Here is a good resource for what constitutes “good code”. Learning good coding practices early in your career will save you hassle later on!

  • The milestones will be equally weighted.

For Milestone 1

To complete this milestone, edit this very .Rmd file directly. Fill in the sections that are tagged with <!--- start your work below --->.

To submit this milestone, make sure to knit this .Rmd file to an .md file by changing the YAML output settings from output: html_document to output: github_document. Commit and push all of your work to the mini-analysis GitHub repository you made earlier, and tag a release on GitHub. Then, submit a link to your tagged release on canvas.

Points: This milestone is worth 36 points: 30 for your analysis, and 6 for overall reproducibility, cleanliness, and coherence of the Github submission.

Learning Objectives

By the end of this milestone, you should:

  • Become familiar with your dataset of choosing
  • Select 4 questions that you would like to answer with your data
  • Generate a reproducible and clear report using R Markdown
  • Become familiar with manipulating and summarizing your data in tibbles using dplyr, with a research question in mind.

Task 1: Choose your favorite dataset

The datateachr package by Hayley Boyce and Jordan Bourak currently composed of 7 semi-tidy datasets for educational purposes. Here is a brief description of each dataset:

  • apt_buildings: Acquired courtesy of The City of Toronto’s Open Data Portal. It currently has 3455 rows and 37 columns.

  • building_permits: Acquired courtesy of The City of Vancouver’s Open Data Portal. It currently has 20680 rows and 14 columns.

  • cancer_sample: Acquired courtesy of UCI Machine Learning Repository. It currently has 569 rows and 32 columns.

  • flow_sample: Acquired courtesy of The Government of Canada’s Historical Hydrometric Database. It currently has 218 rows and 7 columns.

  • parking_meters: Acquired courtesy of The City of Vancouver’s Open Data Portal. It currently has 10032 rows and 22 columns.

  • steam_games: Acquired courtesy of Kaggle. It currently has 40833 rows and 21 columns.

  • vancouver_trees: Acquired courtesy of The City of Vancouver’s Open Data Portal. It currently has 146611 rows and 20 columns.

Things to keep in mind

  • We hope that this project will serve as practice for carrying our your own independent data analysis. Remember to comment your code, be explicit about what you are doing, and write notes in this markdown document when you feel that context is required. As you advance in the project, prompts and hints to do this will be diminished - it’ll be up to you!

  • Before choosing a dataset, you should always keep in mind your goal, or in other ways, what you wish to achieve with this data. This mini data-analysis project focuses on data wrangling, tidying, and visualization. In short, it’s a way for you to get your feet wet with exploring data on your own.

And that is exactly the first thing that you will do!

1.1 (1 point) Out of the 7 datasets available in the datateachr package, choose 4 that appeal to you based on their description. Write your choices below:

Note: We encourage you to use the ones in the datateachr package, but if you have a dataset that you’d really like to use, you can include it here. But, please check with a member of the teaching team to see whether the dataset is of appropriate complexity. Also, include a brief description of the dataset here to help the teaching team understand your data.

1: CHOICE_1_HERE
2: CHOICE_2_HERE
3: CHOICE_3_HERE
4: CHOICE_4_HERE

1.2 (6 points) One way to narrowing down your selection is to explore the datasets. Use your knowledge of dplyr to find out at least 3 attributes about each of these datasets (an attribute is something such as number of rows, variables, class type…). The goal here is to have an idea of what the data looks like.

Hint: This is one of those times when you should think about the cleanliness of your analysis. I added a single code chunk for you below, but do you want to use more than one? Would you like to write more comments outside of the code chunk?

### EXPLORE HERE ###
steam_games
## # A tibble: 40,833 × 21
##       id url    types name  desc_snippet recent_reviews all_reviews release_date
##    <dbl> <chr>  <chr> <chr> <chr>        <chr>          <chr>       <chr>       
##  1     1 https… app   DOOM  Now include… Very Positive… Very Posit… May 12, 2016
##  2     2 https… app   PLAY… PLAYERUNKNO… Mixed,(6,214)… Mixed,(836… Dec 21, 2017
##  3     3 https… app   BATT… Take comman… Mixed,(166),-… Mostly Pos… Apr 24, 2018
##  4     4 https… app   DayZ  The post-so… Mixed,(932),-… Mixed,(167… Dec 13, 2018
##  5     5 https… app   EVE … EVE Online … Mixed,(287),-… Mostly Pos… May 6, 2003 
##  6     6 https… bund… Gran… Grand Theft… NaN            NaN         NaN         
##  7     7 https… app   Devi… The ultimat… Very Positive… Very Posit… Mar 7, 2019 
##  8     8 https… app   Huma… Human: Fall… Very Positive… Very Posit… Jul 22, 2016
##  9     9 https… app   They… They Are Bi… Very Positive… Very Posit… Dec 12, 2017
## 10    10 https… app   Warh… In a world … <NA>           Mixed,(904… May 31, 2019
## # ℹ 40,823 more rows
## # ℹ 13 more variables: developer <chr>, publisher <chr>, popular_tags <chr>,
## #   game_details <chr>, languages <chr>, achievements <dbl>, genre <chr>,
## #   game_description <chr>, mature_content <chr>, minimum_requirements <chr>,
## #   recommended_requirements <chr>, original_price <dbl>, discount_price <dbl>

1.3 (1 point) Now that you’ve explored the 4 datasets that you were initially most interested in, let’s narrow it down to 1. What lead you to choose this one? Briefly explain your choice below.

1.4 (2 points) Time for a final decision! Going back to the beginning, it’s important to have an end goal in mind. For example, if I had chosen the titanic dataset for my project, I might’ve wanted to explore the relationship between survival and other variables. Try to think of 1 research question that you would want to answer with your dataset. Note it down below.

Important note

Read Tasks 2 and 3 fully before starting to complete either of them. Probably also a good point to grab a coffee to get ready for the fun part!

This project is semi-guided, but meant to be independent. For this reason, you will complete tasks 2 and 3 below (under the START HERE mark) as if you were writing your own exploratory data analysis report, and this guidance never existed! Feel free to add a brief introduction section to your project, format the document with markdown syntax as you deem appropriate, and structure the analysis as you deem appropriate. If you feel lost, you can find a sample data analysis here to have a better idea. However, bear in mind that it is just an example and you will not be required to have that level of complexity in your project.

Task 2: Exploring your dataset

If we rewind and go back to the learning objectives, you’ll see that by the end of this deliverable, you should have formulated 4 research questions about your data that you may want to answer during your project. However, it may be handy to do some more exploration on your dataset of choice before creating these questions - by looking at the data, you may get more ideas. Before you start this task, read all instructions carefully until you reach START HERE under Task 3.

2.1 (12 points) Complete 4 out of the following 8 exercises to dive deeper into your data. All datasets are different and therefore, not all of these tasks may make sense for your data - which is why you should only answer 4.

Make sure that you’re using dplyr and ggplot2 rather than base R for this task. Outside of this project, you may find that you prefer using base R functions for certain tasks, and that’s just fine! But part of this project is for you to practice the tools we learned in class, which is dplyr and ggplot2.

  1. Plot the distribution of a numeric variable.
  2. Create a new variable based on other variables in your data (only if it makes sense)
  3. Investigate how many missing values there are per variable. Can you find a way to plot this?
  4. Explore the relationship between 2 variables in a plot.
  5. Filter observations in your data according to your own criteria. Think of what you’d like to explore - again, if this was the titanic dataset, I may want to narrow my search down to passengers born in a particular year…
  6. Use a boxplot to look at the frequency of different observations within a single variable. You can do this for more than one variable if you wish!
  7. Make a new tibble with a subset of your data, with variables and observations that you are interested in exploring.
  8. Use a density plot to explore any of your variables (that are suitable for this type of plot).

2.2 (4 points) For each of the 4 exercises that you complete, provide a brief explanation of why you chose that exercise in relation to your data (in other words, why does it make sense to do that?), and sufficient comments for a reader to understand your reasoning and code.

Task 3: Choose research questions

(4 points) So far, you have chosen a dataset and gotten familiar with it through exploring the data. You have also brainstormed one research question that interested you (Task 1.4). Now it’s time to pick 4 research questions that you would like to explore in Milestone 2! Write the 4 questions and any additional comments below.

Overall reproducibility/Cleanliness/Coherence Checklist

Coherence (0.5 points)

The document should read sensibly from top to bottom, with no major continuity errors. An example of a major continuity error is having a data set listed for Task 3 that is not part of one of the data sets listed in Task 1.

Error-free code (3 points)

For full marks, all code in the document should run without error. 1 point deduction if most code runs without error, and 2 points deduction if more than 50% of the code throws an error.

Main README (1 point)

There should be a file named README.md at the top level of your repository. Its contents should automatically appear when you visit the repository on GitHub.

Minimum contents of the README file:

  • In a sentence or two, explains what this repository is, so that future-you or someone else stumbling on your repository can be oriented to the repository.
  • In a sentence or two (or more??), briefly explains how to engage with the repository. You can assume the person reading knows the material from STAT 545A. Basically, if a visitor to your repository wants to explore your project, what should they know?

Once you get in the habit of making README files, and seeing more README files in other projects, you’ll wonder how you ever got by without them! They are tremendously helpful.

Output (1 point)

All output is readable, recent and relevant:

  • All Rmd files have been knitted to their output md files.
  • All knitted md files are viewable without errors on Github. Examples of errors: Missing plots, “Sorry about that, but we can’t show files that are this big right now” messages, error messages from broken R code
  • All of these output files are up-to-date – that is, they haven’t fallen behind after the source (Rmd) files have been updated.
  • There should be no relic output files. For example, if you were knitting an Rmd to html, but then changed the output to be only a markdown file, then the html file is a relic and should be deleted.

(0.5 point deduction if any of the above criteria are not met. 1 point deduction if most or all of the above criteria are not met.)

Our recommendation: right before submission, delete all output files, and re-knit each milestone’s Rmd file, so that everything is up to date and relevant. Then, after your final commit and push to Github, CHECK on Github to make sure that everything looks the way you intended!

Tagged release (0.5 points)

You’ve tagged a release for Milestone 1.

Attribution

Thanks to Icíar Fernández Boyano for mostly putting this together, and Vincenzo Coia for launching.