This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Homework 5: Fun Times with GGPlot2 | |
======================================================== | |
For this assignment I decided to go out and find some new data, as I was getting a bit tired of working with GapMinder. I decided to check out [NYC Open Data](https://data.cityofnewyork.us/) as I grew up in NY and thought it would be cool to check out. It turns out that there are over 1100 data sets, but luckily there was a good search and sort feature on the site. I ended up settling on a dataset on response times to emergencies by the NYC Fire Department located [here](https://data.cityofnewyork.us/Public-Safety/FDNY-Community-Board-Incident-Count/rtc6-e7ff). | |
The data has 5 different variables: Two are categorical (the borough or location, type of incident) and three are numerical (a count variable for each type of incident, an average time of response, and a date). After playing around a bit I manage to get the CSV loaded with the code below. Before doing so I should note that I had to go into the actual file and c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Homework Number Four (Stat545a) | |
======================================================== | |
In this assignment we will be using the **Gapminder** dataset. (Located [here](http://www.stat.ubc.ca/~jenny/notOcto/STAT545A/examples/gapminder/data/gapminderDataFiveYear.txt "Gapminder dataset on the course website") for those who are curious). | |
The goal of the present assignment is to make use of code which was written by another student. I will use the code from [Mina Park](http://rpubs.com/parkm87/stat545a-2013-hw03_park-min "Many thanks for the well written code!"). | |
But first, we need to load the dataset and do out little sanity check with `str()`, followed by loading up the datasets we need: `lattice` and `plyr`. | |
```{r warning = FALSE} | |
gDat <- read.delim("gapminderDataFiveYear.txt") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Data Aggregation Fun Times! | |
========================= | |
This assignment will once again make use of the **GapMinder** dataset, but this time we will be having fun with the `Plyr` package. | |
Before beginning, I load the dataset, the needed packages, and then do a quick sanity check that my data is what I expect it to be. As a matter of personal preference I make use of the `stringsAsFactors = FALSE` argument when I load the data, to keep R from turning the variables for Country and Continent into factors. | |
```{r warning = FALSE} | |
gDat <- read.delim("gapminderDataFiveYear.txt", stringsAsFactors = FALSE) | |
library(plyr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Homework Number Two (Stat545a) | |
======================================================== | |
In this assignment we will be taking a preliminary look at the **Gapminder** dataset. (Located [here](http://www.stat.ubc.ca/~jenny/notOcto/STAT545A/examples/gapminder/data/gapminderDataFiveYear.txt "Gapminder dataset on the course website") for those who are curious). | |
This will include: | |
* Loading the dataset | |
* Get a sense of the sort of information in the dataset | |
* Summarizing the variables in the dataset | |
* Creating a quick plot of some of the information in the dataset |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n <- 60 | |
a <- 2 | |
b <- 3 | |
sigSq <- 0.5 | |
x <- runif(n) | |
y <- a + b * x + rnorm(n, sd = sqrt(sigSq)) | |
(avgX <- mean(x)) | |
plot(x, y) | |
abline(a, b, col = "red") |