HW 10 - Wrap up!

Photo by Kari Shea on Unsplash

It’s almost time to wrap up the course! In this three part assignment you get to practice what we learned this week, try something new, and get creative!

Getting started

Go to the course GitHub organization and locate your homework repo, clone it in RStudio and open the R Markdown document. Knit the document to make sure it compiles without errors.

Warm up

Before we introduce the data, let’s warm up with some simple exercises. Update the YAML of your R Markdown file with your information, knit, commit, and push your changes. Make sure to commit with a meaningful commit message. Then, go to your repo on GitHub and confirm that your changes are visible in your Rmd and md files. If anything is missing, commit and push again.

Packages

We’ll use the tidyverse package for the first part of this assignment. For the second part you get to choose which package to use.

library(tidyverse)

Exercises

Part 1 - Mirror, mirror on the wall, who’s the ugliest of them all?

Here is a simple plot using the mpg dataset, which contains information on fuel economy of cars. We’re plotting highway miles per gallon vs. city miles per gallon, coloured by whether the car is front-wheel drive, rear wheel drive, or four-wheel drive.

ggplot(data = mpg, aes(x = cty, y = hwy, color = drv)) +
  geom_point()
I realize that "ugly" is subjective, so we're mostly looking to see if you can figure out how to change the look of a plot using help files of functions you haven't learned before.
  1. Make this plot as ugly as possible by changing colours, background color, fonts, or anything else you can think of. You will probably want to play around with theme options, but you can do more. You can also search online for other themes, fonts, etc. that you want to tweak. Try to make it as ugly as possible, the sky is the limit!

🧶 ✅ ⬆️ Knit, commit, and push your changes to GitHub with an appropriate commit message. Make sure to commit and push all changed files so that your Git pane is cleared up afterwards.

Part 2 - You gotta pick a package or two

But really, one is enough. Pick a package from the list below, and use it to do something. If you want to use a package not on this list, that’s also ok, but it needs to be a package we haven’t used in class. If you start with a package and are struggling to get it to work, ask for help on Piazza or just move to another one.

**Remember:** You *install* the package in the Console, not in the R Markdown document since you don't want to keep reinstalling it every time you knit the document.

Your task is to install the package you pick. Depending on where the package comes from, how you install the package differs:

  • If the package is on CRAN (Comprehensive R Archive Network), you can install it with install.packages.
  • If the package is only on Github (most likely because it is still under development), you need to use the install_github function.

Then, load the package. Regardless of how you installed the package you can load it with the library function.

Finally, do something with the package. It doesn’t have to be complicated. In fact, keep it simple. The goal is for you to read and understand the package documentation to carry out a simple task.

**Note:** For the output generated by some of these packages to show up properly, you might need to change the output of your R Markdown document from `github_document` to `html_document` in the YAML of your R Markdown document.
  1. Which package are you using? State the name of the package, whether it was on CRAN or GitHub, and include the code for loading it. Also include a one sentence description of what the package does.Then, do something with the package and provide a brief narrative including code and output. Also comment on difficulties you had, if any, figuring out how to use the package.

Packages on CRAN

These packages can be installed with:

install.packages("PACKAGENAME")
Package Description
cowsay Allows printing of character strings as messages/warnings/etc. with ASCII animals, including cats, cows, frogs, chickens, ghosts, and more
babynames US Baby Names 1880-2015
dragracer These are data sets for the hit TV show, RuPaul’s Drag Race. Data right now include episode-level data, contestant-level data, and episode-contestant-level data
datapasta RStudio addins and R functions that make copy-pasting vectors and tables to text painless
DiagrammeR Graph/Network Visualization
janeaustenr Full texts for Jane Austen’s 6 completed novels, ready for text analysis. These novels are “Sense and Sensibility”, “Pride and Prejudice”, “Mansfield Park”, “Emma”, “Northanger Abbey”, and “Persuasion”
ggimage Supports image files and graphic objects to be visualized in ‘ggplot2’ graphic system
gganimate Create easy animations with ggplot2
gt Easily Create Presentation-Ready Display Tables
leaflet Create Interactive Web Maps with the JavaScript ‘Leaflet’ Library
praise Build friendly R packages that praise their users if they have done something good, or they just need it to feel better
plotly Create interactive web graphics from ggplot2 graphs and/or a custom interface to the JavaScript library plotly.js inspired by the grammar of graphics
suncalc R interface to suncalc.js library, part of the SunCalc.net project, for calculating sun position, sunlight phases (times for sunrise, sunset, dusk, etc.), moon position and lunar phase for the given location and time
schrute The complete scripts from the American version of the Office television show in tibble format
statebins The cartogram heatmaps generated by the included methods are an alternative to choropleth maps for the United States and are based on work by the Washington Post graphics department in their report on “The states most threatened by trade”
ttbbeer An R data package of beer statistics from U.S. Department of the Treasury, Alcohol and Tobacco Tax and Trade Bureau (TTB)
ukbabynames Full listing of UK baby names occurring more than three times per year between 1996 and 2015, and rankings of baby name popularity by decade from 1904 to 1994

Packages on GitHub only

These packages can be installed with:

library(devtools)
install_github("USERNAME/PACKAGENAME")

USERNAME refers to the user name of the developer of the package. For example, for the first package listed below, USERNAME is hadley and PACKAGENAME is emo.

Package Description
bingo Generate Bingo cards
BRRR BRRR extends the beepr package to include a number of rap adlibs
CatterPlots Plots with Cats
cooking Chopping, peeling, frying, and cooking various ingredients, and combining them to a delicious ragout. Also includes buying them from a local supermarket
dadjoke The goal of dadjoke is to make you laugh in spite of yourself
emo The goal of emo(ji) is to make it very easy to insert emoji into RMarkdown documents
emoGG Use Emoji in ggplot2
emokid For those times when you’re having trouble expressing how you feel about your broken code
flametree The goal of flametree is to make pretty pictures
ggbarf Make isotype bars using the vomit emoji
ggCyberPunk Create Cyberpunk area and line plots
ggiraph Create interactive ggplot2 graphics using htmlwidgets
ggkeyboard Plot a Keyboard Using ggplot2
jasmines Make generative art
kandinsky Turn any dataset into a Kandinsky painting
lego This R data package contains information about every Lego set manufactured from 1970 to 2015, a total of 6172 sets
linkinpark Data package that contains a few different datasets about the band
prenoms First names given to babies in metropolitan France between 1900 and 2015
raybonsai Generate 3D procedural trees in R, rendered with rayrender! Procedural generation code based on the flametree package by Danielle Navarro.

🧶 ✅ ⬆️ Knit, commit, and push your changes to GitHub with an appropriate commit message. Make sure to commit and push all changed files so that your Git pane is cleared up afterwards and review the md document on GitHub to make sure you’re happy with the final state of your work.