-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtemplate.Rnw
More file actions
101 lines (69 loc) · 2.59 KB
/
Copy pathtemplate.Rnw
File metadata and controls
101 lines (69 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
\documentclass[man,biblatex]{apa6}
\usepackage{epsfig,amsmath,alltt,bm,url,subcaption}
%% This keeps the tildes out when you use Rnw2pdf:
\usepackage[english]{babel}
\addbibresource{refs.bib}
\title{A paper}
\twoauthors{Author 1}{Author 2}
\twoaffiliations{University 1}{University 2}
\abstract{
abstract here}
\authornote{Thanks.
Correspondence to Author 1, address.
Email: .}
\shorttitle{A paper}
\rightheader{A paper}
\let\proglang=\textsf
\let\pkg=\emph
\let\code=\texttt
%% for internal use
\newcommand{\fixme}[1]{\emph{\marginpar{FIXME} (#1)}}
\newcommand{\readme}[1]{\emph{\marginpar{README} (#1)}}
%\spacing{1}
\begin{document}
\maketitle
<<preliminaries, echo=FALSE, message=FALSE, warning=FALSE>>=
library("knitr")
## global knitr options
opts_chunk$set(echo=FALSE, fig.path='figure/',fig.align='center',fig.show='hold',size='footnotesize', cache.path="cache/", warning=FALSE, message = FALSE)
@
Intro text. References can be obtained like this \autocite{merzei13}. Or, just putting the year in parentheses: ``\textcite{merzei13} did some research.''
Here is another reference I added \autocite{tregel80}.
\section{Section header}
Section text.
\section{Section header}
<<reg, echo=FALSE>>=
data(USArrests)
m1 <- lm(Murder ~ UrbanPop, data=USArrests)
@
Just above this text, we have R code that fits a regression model. We can pull out some results from this model in the text. For example, the slope is \Sexpr{round(coef(m1)[2],2)}. We can also include code to create a graph; see Figure~\ref{fig:fig1} and Figure~\ref{fig:fig2}.
\begin{figure}
\caption{Residual plot.}
\label{fig:fig1}
<<fig1,echo=FALSE,fig.show="asis",out.width="3in",out.height="3in",fig.align="center">>=
with(m1, plot(fitted.values, residuals, xlab="Fitted", ylab="Residual",
pch=20))
@
\end{figure}
\begin{figure}
\caption{Scatter plot.}
\label{fig:fig2}
<<fig2,echo=FALSE,fig.show="asis",out.width="3in",out.height="3in",fig.align="center">>=
plot(USArrests$UrbanPop, USArrests$Murder, xlab="Urban Population", ylab="Murder", pch=20)
@
\end{figure}
\subsection{Subsection 1}
\subsection{Subsection 2}
\section{Section header}
\subsection{Method}
\subsection{Results}
\section{General Discussion}
In this paper, we showed some things\ldots
\section*{Computational Details}
All results were obtained using the \proglang{R}~system for statistical computing \autocite{r16},
version~\Sexpr{paste(R.Version()[6:7], collapse = ".")}.
\proglang{R}~is
freely available under the General Public License~2 from the
Comprehensive \proglang{R} Archive Network at \url{http://CRAN.R-project.org/}..
\printbibliography
\end{document}