--- title: "Untitled" author: "David Harvey" date: "August 29, 2016" output: pdf_document --- This is a template `.Rmd` file that you can use as a model if you decide to use Rmarkdown to present your solutions to long problem sets. An `.Rmd` file uses a combination of Markdown to specify how text is formatted, and uses embedded `R` code to manipulate data and create plots. When you `knit` the file into a `pdf` format, the Markdown coding formats your text and the `R` code is run and the results inserted into the `pdf` file. The lines at the top of the document, which are placed between the two sets of three dashes, are called yaml (which stands for **y**aml **a**in't **m**arkdown **l**anguage); replace the character strings for `title`, `author`, and `date` so that they reflect your work. Here is my solution to a hypothetical problem from a long problem set in which we are asked to look at some data drawn at random from a uniform distribution; that is, data that simulates random noise. **Problem 1** I might start my solution to this problem by explaining the approach I plan to take and, perhaps, some comments on how I am going to use `R` to solve the problem. Next, I might embed some `R` commands and create the appropriate output, which in this example will include some summary statistics and a plot. The embedded `R` commands are called a code chuck, which begins by typing three back ticks and {r} followed by lines of `R` code, and that ends by typing three back ticks. When `knit` into a `pdf` file, the embedded code is displayed along with the results generated by `R`. ```{r} # first we create the vector x, which contains the indecies for our random numbers # and the vector y, which contains the 100 random numbers drawn form a uniform # distribution defined by a minimum of -1 and a maximum of +1 x = seq(1:100) y = runif(100, min = -1, max = 1) # the following commands return the mean, the standard deviation, and the median # values for our 100 random numbers mean(y) sd(y) median(y) # finally, we plot the random numbers as a function of their indicies and add a # dashed red line to show the mean value plot(x, y, pch = 19, col = "blue", ylab = "random uniform values", xlab = "index", type = "l") abline(h = mean(y), col = "red", lty = 2) ``` **Problem 2** **Problem 3** ...and so on. To convert a `.Rmd` file into a `.pdf` file, use the `Knit PDF` button and save it to your working directory. You can work out your sequence of commands within this document and reknit as needed, or you can work out your sequence of commands in the console and then cut and paste commands into your `.Rmd` file. Adding comments to your code chunks is a useful way to document what you are doing. To create a new `.Rmd` file, click on the add a file button (or select File: New File: R Markdown... from the Menu bar). To learn about using Markdown to format a document, select Help: Markdown Quick Reference from the main menu in RStudio. You will find examples in the help file for formatting text (*italic* font, **bold** font, ^superscripts^, and ~subscripts~), for creating lists (both ordered and unordered), for creating headers, for inserting hyperlinks and images, and for creating tables. You can even use Rmarkdown to enter equations, although this requires some knowledge of LaTeX. The best way to learn is to experiment and ask questions.