```{r, echo=FALSE, warning=FALSE, message=FALSE}
# this chunk sets the chunk options for the whole document
require(knitr)
opts_chunk$set(warning=FALSE, message=FALSE)
```

## Manipulating vectors

Please run the following commands in order to set up the following exercises.

```{r}
require('ggplot2')
load(url('http://www.stolaf.edu/people/olaf/cs125/hw8.RData'))
```

Note that this loads several objects into your environment: 8 vectors of data and
a new function called `draw`.  If at some point you want to restore the data, it 
is fine to paste these commands in again whenever you need them. 

Let's see whether the drawing function is working correctly. Try typing in the 
following command and see what it does:

```{r}
draw(p0x, p0y)
```

If all goes well, a simple sketch of Calvin should appear. If you print `p0x`, 
you will see that it is a vector of numbers, and `p0y` is another vector of 
numbers, both of the same length. `p0x` and `p0y` contain the x and y coordinates, 
respectively, of the points along the line segments that make up the simple Calvin 
sketch. As an experiment, try the following:

```{r}
draw(p0x, p0y + 25)
```

Hopefully, the result is that Calvin appeared to move up a distance of 25 units. 
Before proceeding with the exercises, please think through what is happening with 
these commands, since it will be easier to answer the following questions if you 
clearly understand how the two vectors are related to the plot.

1.   Let's take a look at the another drawing:

```{r}
draw(p2x, p2y)
```

here, we almost have four duplicates of Calvin in several places, but the upper 
right drawing has been shifted to the left. Please move that part of the drawing 
to the right, so that the four Calvins are symmetrically placed (the same distance 
apart both horizontally and vertically).

SOLUTION:


3.   Let's take a look at a third example:

```{r}
draw(p3x, p3y)
```

here, we almost have four duplicates of Hobbes in several places, but every other 
point has been moved five units up and to the right, making it almost impossible 
to see Hobbes anywhere. Please try to resolve the four duplicates of Hobbes.

SOLUTION:


* * * 

## Manipulating dataframes

4.   Show the code to create a data frame such that the first column contains the built-in "letters" data set and the second column contains the integers from 1 to 26.

SOLUTION:


* * *

For the following exercises, load in the built in earthquake data set.

```{r, eval=FALSE}
data(quakes)
```

5.  How would you find information about this data frame? How many rows and 
    columns does it have?
    
    SOLUTION:


6.  Based purely on the description of the columns (found with `?quakes`), would
    you expect a relationship between the 4th and 5th columns? Why or why not?
    
    SOLUTION:


7.  Show a command you could use to find the average (mean) magnitude of all 
    earthquakes that occurred below the median depth of all earthquakes.
    
    SOLUTION:


8.  How does the average magnitude of these "deep" earthquakes compare to the 
    magnitude of "shallow" (above median depth) earthquakes?
    
    SOLUTION:


9.  Show the command you would use to get the row(s) with the smallest value in 
    the `depth` column.
    
    SOLUTION:


10. Can you think of an interesting plots you would like to create?  Please 
    experiment around with plotting.
    
    SOLUTION:



