Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

BOOK: Popper, K. R. (1935) Logik der Forschung. Springer, Wien 

BOOK: Jaynes, E. T. (2003) Probability Theory. Cambridge University Press. A somewhat different view on probability and statistics.

LaTeX and RStudio

Brief introduction to LaTeX

...

You can of course copy-paste your R code in LaTeX (using e.g. the package listings for syntax formatting) and save graphics to include, but here the advantage is:

This enables the creation of dynamic reports that are updated automatically if data or analysis changes.

This means Sweave is very useful for "on going" projects, where things are expected to change, as well as quick notes on something you are working on.

Ref:

https://support.rstudio.com/hc/en-us/articles/200552056-Using-Sweave-and-knitr

LaTex in RStudio

First, install the knitr package:

> install.packages("knitr")

Set knitr as default for Rnw files: https://support.rstudio.com/hc/en-us/articles/200532247

Open a new file of type "R Sweave", it will automatically contain:

...

\documentclass{article}

\usepackage[utf8]{inputenc}

\usepackage{framed}

\usepackage{graphicx}

%\usepackage{hyperref}

%\usepackage[hdivide={2cm, *, 2cm}, vscale=0.85]{geometry}

%\usepackage[backend=bibtex]{biblatex}

%\usepackage{listings}

 

\title{Correlation analysis of the wildlings' deaths and the rise of white walkers}

\author{John Snow}

\date{}

\begin{document}

\maketitle

\section{Introduction}

\end{document}

 and  save the file (the authomatic file extension will be .Rnw) and try to compile the

 

 

Sweave and knitr

You can of course copy-paste your code in LaTeX (using e.g. the package listings for syntax formatting) and save graphics to include, but here the advantage is:

This enables the creation of dynamic reports that are updated automatically if data or analysis changes.

This means Sweave is very useful for "on going" projects, where things are expected to change, as well as quick notes on something you are working on.

Ref:

https://support.rstudio.com/hc/en-us/articles/200552056-Using-Sweave-and-knitr

Setting knitr as default for Rnw files

Ref:

file ("Compile PDF" button). You should be prompted a PDF: congratulations, this is your first LaTeX file!

Sweave

Readapting the file http://leisch.userweb.mwn.de/Sweave/example-1.Snw to work with knitr, we can add this example of including a plot in LaTeX from a R built-in dataframe:

\begin{figure}

<<boxplot, eval=TRUE, echo=FALSE>>=

boxplot(Ozone ~ Month, data = airquality)

@

\caption{This is some caption.\label{lab}}

\end{figure}

 

 

http://www.statistik.lmu.de/~leisch/Sweave/Sweave-manual.pdf

 https://support.rstudio.com/hc/en-us/articles/200532247

Coming soon