---
title: 'Homework 0: Description'
author: "Jane Doe"
output:
  github_document: default
---

This document serves as a template for submitting a homework assignment. I modified this slightly from RStudio's default template.

Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. See [here](https://help.github.com/articles/basic-writing-and-formatting-syntax/) for styling Markdown documents (e.g., headers, links, italics, etc.). The knitr package allows us to mix R code within Markdown documents and output to variety of formats. For more details on using R Markdown see <http://rmarkdown.rstudio.com>. 

Because I set the output as `github_document` (see header at the top), the **Knit** button generates a `.md` document that includes text, code, and figures. GitHub renders this `.md` file nicely. If you change the output above, you can render `.pdf`, `.docx`, or `.html` files instead. When pushing documents to GitHub, use `.md` by default.

## Use LaTeX Equations

R Markdown can render LaTeX equations for *some* output formats. While the `.md` file output for `github_document` looks nice on GitHub, it doesn't render equations. If you must render an equation in a document on GitHub, you have two options.

1. You can use LaTeXit to create a `.png` image of the equation and [include](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#images) that as an image in the document. I take this approach in [this README](https://github.com/carlislerainey/latent-dissent/tree/aefecf90e734bd270889a1280571ea87795af34d).
1. You can change from `github_document` to `pdf_document`. This uses LaTeX to create a pdf that has equations nicely rendered. You can change the output to pdf by using the following:
```
output:
  pdf_document
``` 

## Embed R Code

You can embed an R code chunk and output like this:

```{r}
summary(cars)
```

### Including Plots

You can also embed plots, for example:

```{r, echo = FALSE}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

Usually, you want your code visisible for the assignment, so avoid `echo = FALSE` by default. For example:

```{r}
plot(pressure)
```

### A Weird Feature of R Markdown

Usually, we start a project by starting a new R Project, which creates a `.Rproj` file. We begin working on the project by cicking that `.Rproj` file. All filepaths are then relative to the location of that `.Rproj` file. For example, `read_csv("data/parties.csv")`, trys to find the file `parties.csv` in the `data` subdirectory of the project *regardless of where the R sript is saved*.

But with R Mardown documents, all filepaths are relative to the location of the `.Rmd` file. There are inconvenient workarounds, but we'll solve the issue by keeping our `.Rmd` file in the same directory as the `.Rproj` file. See the discussion [here](https://stackoverflow.com/questions/42287348/issue-working-directory-in-r-studio-stuck-on-directory-containing-open-r-mark).

For our purposes, use the following file structure for R Markdown documents:
```
hw00-jane-doe/
  |-- hw00-jane-doe.Rproj
  |-- hw00.Rmd
  |-- raw-data.csv
  |-- hw00_files/    <- generated with knitr from hw00.Rmd
  |-- hw00.md        <- generated with knitr from hw00.Rmd
```
If you want to use R Markdown as part of a larger project, but not have them clutter the project directory, I can show you the workaround.
