Created
August 23, 2016 23:28
-
-
Save MGallow/08ffab533e1c60edaf7a512c1ad9058d to your computer and use it in GitHub Desktop.
sample homework templates for RMarkdown and R Sweave.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "R Markdown Homework Template" | |
author: "NAME HERE" | |
affiliation: "UNIVERSITY HERE" | |
abstract: | |
thanks: | |
keywords: | |
date: \today | |
output: | |
pdf_document: | |
highlight: default | |
citation_package: | |
keep_tex: false | |
fig_caption: true | |
latex_engine: pdflatex | |
fontsize: 11pt | |
geometry: margin=1in | |
bibliography: | |
biblio-style: | |
header-includes: | |
- \usepackage{indentfirst} | |
- \usepackage{graphicx} | |
- \usepackage{geometry} | |
- \usepackage{subfigure} | |
- \usepackage{amsmath} | |
- \usepackage{listings} | |
- \usepackage{tikz} | |
- \usetikzlibrary{matrix} | |
--- | |
\vspace{0.25in} | |
# 1. "PROBLEM NUMBER ONE" | |
This is a simple homework assignment template. Notice that in the previous line we can create a header for our problem number by using a single "#". The text is then automatically bolded and indented. Below we will create a sublist. This should be used if problems have more than one part. | |
a. "PROBLEM NUMBER ONE, PART A" | |
b. | |
c. | |
d. | |
e. | |
# 2. "PROBLEM NUMBER TWO" | |
Suppose we need to input an R chunk into our homework file. In this case, the following syntax should be used. Note that "'''" signifies we are include chunks of code (We may also tweak the options as necessary). | |
```{r tidy = TRUE, message = FALSE, warning = FALSE, error = FALSE} | |
#input R code here. Examples: | |
#define R list | |
x = c(1,2,3,4,5) | |
#make plot | |
plot(x) | |
``` | |
Below the R code, we can provide additional descriptions and/or explain our code more thoroughly. | |
# 3. "AND REPEAT...." | |
```{r tidy = TRUE, message = FALSE, warning = FALSE, error = FALSE} | |
#again, we can input our R code here. | |
``` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[a4paper]{book} | |
\usepackage{amssymb} | |
\usepackage[english]{babel} | |
\usepackage[utf8]{inputenc} | |
\usepackage{fancyhdr} | |
\usepackage{bm} | |
\usepackage[margin=1in]{geometry} | |
\pagestyle{fancy} | |
\fancyhf{} | |
\rhead{NAME HERE} | |
\lhead{COURSE HERE} | |
\rfoot{Page \thepage} | |
\begin{document} | |
<<include=FALSE>>= | |
library(knitr) | |
opts_chunk$set( | |
concordance=TRUE | |
) | |
@ | |
\title{R Sweave Homework Template} | |
\author{NAME HERE} | |
\maketitle | |
\section*{"PROBLEM NUMBER ONE"} | |
This is a simple homework assignment template. Notice that in the previous line we can create a header for our problem number by using a single "section*{}". The text is then automatically bolded and indented. Below we will create a sublist. This should be used if problems have more than one part.\\ | |
\begin{itemize} | |
\item{subpart one} | |
\item{subpart two} | |
\item{subpart three} | |
\end{itemize} | |
\section*{"PROBLEM NUMBER TWO"} | |
Suppose we need to input an R chunk into our homework file. In this case, the following syntax should be used. Note that "'''" signifies we are include chunks of code (We may also tweak the options as necessary).\\ | |
<<>>= | |
#input R code here. Examples: | |
#define R list | |
x = c(1,2,3,4,5) | |
#make plot | |
plot(x) | |
@ | |
Below the R code, we can provide additional descriptions and/or explain our code more thoroughly. | |
\section*{"PROBLEM NUMBER THREE} | |
<<>>= | |
#again, we can input our R code here. | |
@ | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that Github attempted to render the RMarkdown file as a Markdown file and thus the preview looks funky. You are better off just looking at the raw code.