---
title: "Markdown and Network Plotting"
output: html_document
---

# Introduction

This is an [R Markdown](http://rmarkdown.rstudio.com) file. The goal of RMarkdown is to write documents and reports that intersperse text and code.

The text is written in [markdown](https://rmarkdown.rstudio.com/authoring_pandoc_markdown.html). It has lots of different formatting options. Just take a look at this document for example, such as the "Introduction header" or the links in this section.

## Making documents

You can either interact with RMarkdown files within RStudio or "knit" them into finished documents. To create a finished document, click

When you execute code within the notebook, the results appear beneath the code. 

Try executing this chunk by clicking the *Run* button within the chunk (the green triangle) or by placing your cursor inside it and pressing `Ctrl+Shift+Enter`. 

```{r}
x <- c(43,643,765)

print(paste0("The mean of x is ", mean(x)))
```

## Writing code

Code that will be run is marked with three backticks (\`) followed by `{r}` and ends with three backticks. The simplest way to create a code block is to do `Ctrl+Alt+I` or to click the green `Insert` button at the top of the Markdown window.

By default, the code and the output will appear in the created document, but you can set `echo=FALSE` and it will just show the output. Typically, you would want to do this when you're creating a plot.

For example, this is how you create a scatterplot. Try to run this and make sure that it works.

```{r echo=FALSE, message=FALSE}
library(tidyverse)
mtcars %>%
  ggplot() +
  geom_point(aes(x=mpg, y=disp))

```

When you ran the code above you may have gotten an error in the console (the bottom-right pane in RStudio) that said something like "there is no package called 'tidyverse'". If you get this error, then you need to install the tidyverse package. You do that by copying and pasting this code into the console, and pressing enter: `install.packages('tidyverse')`.

## Assignment

The code above has lots of crazy stuff going on with lots of strange symbosl - `%>%` and `()`, etc. We will talk about those in future lessons and you will learn what that all means.

But another way of learning is by playing around, even when you don't understand. For this (very brief) assignment, play with the code above and see if you can figure out how to reverse things so that the miiles per gallon is on the y axis, and the displacement is on the x axis.

```{r}

# Your new plotting code here

```

### Challenge Assignments

Feel free to use Google / StackOverflow to help you.

First, try to make all of the points in the scatterplot a different color.

```{r}

# Your new plotting code here

```

Next, see if you can change the color of the scatterplot points based on the number of cylinders in the engine (Hint: you can run `mtcars` to see the data; `cyl` is the name of the column for cylinders)

```{r}

# Your new plotting code here

```
