This week covers:
- An intro to Git and Github for sharing code
- Command line tools
- R and the Tidyverse
Install tools: Visual Studio Code, Git for Windows, R
- Install Visual Studio Code which will be your main text editor
- Install Git for Windows using the "Git for Windows installer"
- Open Git Bash and check that you have git under bash by typing
git --versionin the terminal
- Do the same within Visual Studio Code
- Download and install R from a CRAN mirror
- Verify that you can see the same set of files through Git Bash and your Windows Explorer by opening Git Bash and typing
lsandpwdto see the contents of your current directory and its location - Navigate to Windows Explorer and see if you can find the same directory and check its contents
- Sign up for a free GitHub account
- Then follow this guide to fork your own copy of the course repository
- Clone a copy of your forked repository, which should be located at
https://github.com/<yourusername>/coursework.git, to your local machine - Once that's done, create a new file in the
week1/studentsdirectory,<yourfirstname>.txt(e.g.,jake.txt) - Use
git addto add the file to your local repository - If needed, set your git username and email with
git config --global user.name "Your Name"andgit config --global user.email "you@youremail.com" - Set your default git editor to VSCode using
git config --global core.editor "code --wait" - Use
git commitandgit pushto commit and push your changes to your copy of the repository - Then issue a pull request to send the changes back to the original course repository
- Finally, sync changes from the main repo to your fork with
git pull upstream master(if your machine doesn't recognizeupstream, do the following to create theupstreamshortcut:git remote add upstream https://github.com/msr-ds3/coursework.git)
- Codecademy's interactive introduction to git
- More resources from GitHub available here
- And here's a handy cheatsheet
Think about how to write a musical_pairs.sh script to determine your programming partner each day. We want the script to do the following:
- Produce a (pseudo)random pairing of 6 groups of 2 people who get to work together each day on pair programming assignments
- Any one of us should be able to run the script and get the same pairing on a given day (i.e., as long as our computers agree on the year/month/day)
- It's interesting to think about how we might avoid repeated pairs from one day to the next, but for a first cut (and maybe final cut) version of the script you can ignore that issue
- See this intro to the command line notebook
- Read through Lifehacker's command line primer
- See Linux Journey's shell lesson
- See this crash course for more details on commonly used commands
- Check out Software Carpentry's guide to the Unix shell
- Review this wikibook on data analysis on the command line, covering
cut,grep,wc,uniq,sort, etc - Learn awk in 20 minutes
- Check out some more advanced tools for Data Science at the Command Line
- Do Codecademy's interactive command line tutorial (the free portion)
- See these Introduction to Counting slides
- Install the GitHub Copilot and GitHub Copilot Chat extensions for Visual Studio Code
- Pull changes from the msr-ds3/coursework repo:
git pull upstream master - Use the download_trips.sh file to download Citibike trip data by running
bash download_trips.shor./download_trips.sh - Fill in solutions under each comment in citibike.sh using the
201402-citibike-tripdata.csvfile
- Make sure to save your work and push it to GitHub. Do this in three steps:
git addandgit commitand new files to your local repository. (Omit large data files.)git pull upstream masterto grab changes from this repository, and resolve any merge conflicts, commiting the final results.git push origin masterto push things back up to your GitHub fork of the course repository.
- Finish by submitting a pull request with your solutions so we can review them! (We won't merge the request, but it's a good way for the TA to provide feedback.)
- Install the R extension for VSCode
- Install the R language server by typing the following in an R terminal:
install.packages("languageserver") - Install the
tidyversepackage, which includesdplyr,ggplot2, and more, in an R terminal:install.packages('tidyverse', dependencies = T)
- See the Data Wrangling in R slides
- Review intro_to_r.ipynb for an introduction to R
- See Chapter 3 of the 2nd edition of R for Data Science for the basics of dplyr
- Use the musical pairs script to determine your programming partner each day
- Open VSCode in the coursework repository and set the working directory to week1 with
setwd('week1') - Fill in solutions to the counting exercises under each comment in citibike.R
- Do the following exercises from Chapter 5 of the 1st edition of R for Data Science:
-
See this video tutorial for tips for R in VSCode
-
Do the free portion of Codecademy's introduction to R, chapters 1, 2, and 3
-
References:
- Basic types: (numeric, character, logical, factor)
- Vectors, lists, dataframes: a one page reference and more details
- Cyclismo's more extensive tutorial
- Posit's data transformation cheatsheet
- The tidyverse style guide
- Hadley Wickham's style guide
- The dplyr vignette
- Sean Anderson's dplyr and pipes examples on github
-
Tutorials:
- DataCamp's introduction to R tutorials (or Hadley's Advanced R if you're a pro)
- DataCamp's Data Manipulation with dplyr tutorial
- Datacamp's Introduction to the Tidyverse tutorial
- See the Data visualization slides
- Review visualization_with_ggplot2.ipynb for an introduction to data visualization with ggplot2
- Do the following exercises from Chapter 3 of the 1st edition of R for Data Science and do the following exercises:
- Citibike plots
- Run the load_trips.R file to generate
trips.RData - Write code in plot_trips.R to create visualizations using
trips.RData
- Run the load_trips.R file to generate
- Read Chapters 1, 9, and 10 of the 2nd edition of R for Data Science on visualization
- Tutorials:
- DataCamp's Data Visualization with ggplot2 (part 1) tutorial
- References:
- Posit's data visualization cheatsheet
- Sean Anderson's ggplot2 slides (code) for more examples
- The R Graphics Cookbook
- The official ggplot2 docs
- Videos on Visualizing Data with ggplot2