knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Assignments in MQIM 6604 should be completed submitted in Rmarkdown. Rmarkdown is an interactive document that combines text and executable R code in a format that facilitates reproducible research. R code is added to the documents in chunks, either inline (within a line of text) or as a separate code block. An inline code chunk would look like
cat("`` `r 2+2` ``")
and when the document is compiled, the code ("2+2" in this case) would be executed, and the answer r 2+2
would show inline in the block of text.
Code that is included in a separate chunk will (when rendered into HTML) look like:
library(quantmod,quietly=TRUE) getSymbols("^GSPC") head(GSPC)
This code chunk will produce:
library(quantmod,quietly=TRUE) getSymbols("^GSPC") head(GSPC)
Please read through a simple introduction to Rmarkdown such as https://rmarkdown.rstudio.com/articles_intro.html.
Note that it is almost always easier to use the tag "output: html_document" while working on an assignment, as compiling directly to pdf can be a bit of a hassle when considering placement of figures of tables. My recommendation is to always use the "output: html_document" tag in Rstudio/Rmarkdown, and if you want PDF output, do this at the end with the "output: pdf_document" or by printing to PDF later. You will need \LaTeX installed on your system to use "output: pdf_document".
Assignments should separate questions with "##" headings, such as:
Use the package quantmod to download historical daily prices on the S&P 500 from Yahoo!Finance with the getSymbols() function. Plot the Adjusted Close.
library(quantmod) getSymbols("^GSPC") chart_Series(GSPC)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.