Skip to content

Instantly share code, notes, and snippets.

@amandammor
amandammor / stat545a-2013-hw05_yuen-ama
Created October 6, 2013 17:30
STAT 545A Homework #5
STAT 545A Homework #5
========================================================
Prepared by: Amanda Yuen
Up to this point, we have learned how to generate plots using the lattice package. For homework #5, we will practice generating plots using the ggplot2 package. I'm going to attempt to reproduce some plots from Homework #4 using ggplot2 to compare the results from the lattice and ggplot2 packages. The goal is to make at least two figures, with one being a stripplot-type of figure (one quantitative variable and one categorical variable) and one being a scatterplot (two quantitative variables).
As always, we start by importing the [Gapminder](http://www.stat.ubc.ca/~jenny/notOcto/STAT545A/examples/gapminder/data/gapminderDataFiveYear.txt) data into R and then doing a quick check that the data has been imported properly.
```{r}
gDat <- read.delim("gapminderDataFiveYear.txt")
@amandammor
amandammor / stat545a-2013-hw04_yuen-ama.Rmd
Last active December 24, 2015 06:48
STAT 545A Homework #4
STAT 545A Homework #4
========================================================
Prepared by: Amanda Yuen
For homework #4, we will evaluate code prepared by someone else for last week's data aggregation tasks and produce graphics to accompany these tasks.
As always, we begin by importing the [Gapminder](http://www.stat.ubc.ca/~jenny/notOcto/STAT545A/examples/gapminder/data/gapminderDataFiveYear.txt) data into R and do a quick check that the data has been imported properly.
```{r}
@amandammor
amandammor / stat545a-2013-hw03_yuen-ama.Rmd
Last active December 23, 2015 16:59
STAT 545A Homework #3
STAT 545A Homework #3
========================================================
Prepared by: Amanda Yuen
This is an R Markdown document. For homework #3, we will perform some data aggregation tasks on the [Gapminder](http://www.stat.ubc.ca/~jenny/notOcto/STAT545A/examples/gapminder/data/gapminderDataFiveYear.txt) data.
First, let's import the data into R.
```{r}
gDat <- read.delim("gapminderDataFiveYear.txt")
@amandammor
amandammor / stat545a-2013-hw02_yuen-ama.Rmd
Created September 13, 2013 23:08
STAT 545A Homework #2
STAT 545A Homework #2
========================================================
Prepared by: Amanda Yuen
This is an R Markdown document. For homework #2, we will carry out a brief analysis of the Gapminder data located [here](http://www.stat.ubc.ca/~jenny/notOcto/STAT545A/examples/gapminder/data/gapminderDataFiveYear.txt).
Let's import the data into R:
```{r}
@amandammor
amandammor / stat545a-2013-hw01_yuen-ama.R
Created September 13, 2013 01:04
STAT 545A Homework #1
a <- 2
b <- -3
n <- 40
sigSq <- 0.5
x <- runif(n)
y <- a + b * x + rnorm(n, sd = sqrt(sigSq))
(avgX <- mean(x))
write(avgX, "avgX.txt")
plot(x,y)
abline(a, b, col = "purple")