This is a very quick introduction to R Markdown. For more details, see http://rmarkdown.rstudio.com/index.html.
Click “run chunk” to run a single chunk of code. Click “Knit” to create an html (or other format) document. By default, R studio with R Markdown installed shows results in notebook style. To turn this off, click the gear icon in the document toolbar and select “Chunk output in console.”
When turning in assignments, each problem should be identified using a level 1 header (Level 1 headers can be made by preceding text with #). Please submit HW in html format using polylearn.
Here is my solution to problem 0.1
If a problem has sub parts, please identify like this.
Solution to part (b).
Here is some text followed by some R code.
x=ts(rnorm(100))
y=filter(x,rep(1/5,5))
summary(x)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -2.32500 -0.84160 -0.09632 -0.12520 0.59450 2.23400
The following options can be used to modifu the display of code and results:
include = FALSE prevents code and results from appearing in the finished file. R Markdown still runs the code in the chunk, and the results can be used by other chunks.
echo = FALSE prevents code, but not the results from appearing in the finished file. This is a useful way to embed figures.
message = FALSE prevents messages that are generated by code from appearing in the finished file.
warning = FALSE prevents warnings that are generated by code from appearing in the finished.
fig.cap = “…” adds a caption to graphical results.
See the R Markdown Reference Guide for a complete list of knitr chunk options.
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -2.35100 -0.70000 0.06647 -0.06773 0.65090 2.93900
You can include inline code like this: -2.351, -0.7, 0.06647, -0.06773, 0.6509, 2.939..
Here is how to make sub-bullets:
End of bullet list
Here is how to make an enumeration list:
Here is a definition list (note that 2 spaces or a tab are required before the description text)
This is such a complicated problem… Hopefully this figure will really clear things up.
ts.plot(cbind(x,y), main="Sample plot", col=c(1:2))
Markdown provides a simple way of formatting text. Here is emphasized text or like this. Or bold or like this.
Math can be formatted using tex, like this \(x=y\).for inline math. Here are a few examples of displayed equations \[ x = \int y\, dy \]
\[ \alpha = \beta \times \gamma + \frac{z^2 - 3y}{3\sqrt{zy}} \]
\[ z = \sum_{i=1}^\infty x_i \]
Look up a tex reference like https://en.wikibooks.org/wiki/LaTeX for more details.