1
\documentclass[12pt]{report}
4
%% This is an Sweave file. To generate a latex file from this, use (in R):
6
%% > Sweave("HVTNscenarios")
7
%% and then in a regular Unix (or MSDOS, or...) shell,
8
%% $ latex HVTNscenarios
9
%% to generate the results.
12
%% The following is for creating PDF.
14
\ifx\pdfoutput\undefined
15
\pdffalse % not running PDFLaTeX
17
\pdfoutput=1 % running PDFLaTeX
22
% \usepackage{thumbpdf}
24
%\usepackage{html,heqn,htmllist}
25
%\usepackage[latex2html]{hyperref}
27
\usepackage[pdftex]{graphicx}
28
\usepackage[pdftex]{hyperref}
30
\usepackage[dvips]{graphicx}
31
\usepackage[dvips]{hyperref}
35
\usepackage[authoryear,round]{natbib}
38
\addtolength{\oddsidemargin}{-0.5in}
39
\addtolength{\textheight}{0.2in}
40
\addtolength{\textwidth}{1in}
42
\hypersetup{backref,colorlinks=true,pagebackref=true,
43
hyperindex=true}%pdfpagemode=FullScreen,
46
\DeclareGraphicsExtensions{.jpg,.pdf,.png,.mps}
64
An example for using Sweave.
67
%% For setting graphics for Sweave
68
%\setkeys{Gin}{width=5cm}
69
%\setkeys{Gin}{width=0.8\textwidth}
71
Possible settings for sweave chunks:
74
\item fig=TRUE, eps=FALSE
75
\item results=hide, tex
81
Indexing works. You can see that from Table~\ref{tab:1} and
82
Figure~\ref{fig:control}.
94
<<Check library existence,echo=FALSE,eval=TRUE>>=
95
xtableExists <- require(xtable)
98
We have our first table
100
<<example output for data 1,results=tex,echo=FALSE>>=
106
and the second table, with Caption and \LaTeX{} reference label.
108
<<example output for data 1,results=tex,echo=FALSE>>=
110
xtable(my.lm.fit,caption="My First Table Caption",label="tab:1")
116
We could do the same thing and echo the code, as well:
118
We have our first table
120
<<example output for data 1,results=tex,echo=TRUE>>=
128
and the second table, with Caption and \LaTeX{} reference label.
130
<<example output for data 1,results=tex,echo=TRUE>>=
132
xtable(my.lm.fit,caption="My Second Table Caption",label="tab:2")
139
Normally you can just include plots, by specifying that the chunk
142
<<exampleFigureOne,fig=TRUE,echo=FALSE>>=
143
plot(rnorm(10),rnorm(10))
148
However, if you want more control, such as Labels on figures as well
149
as floating placement (i.e. letting \LaTeX{} place it for you
150
appropriately), you might:
154
<<exampleFigureTwo,fig=TRUE,echo=FALSE>>=
155
plot(rnorm(10),rnorm(10))
157
\caption{Example of more control}