Dear all,

This week we will learn how to use \(\LaTeX\) to create tables and how to print figures. As a matter of fact, we are using R to gives us figures and tables that we can directly implement in \(\LaTeX\).

Let’s start.

Gerko


This week there is a chain of documents that tell you how to approach tables and figures in \(\LaTeX\) when using R. These documents can serve as a reference for you to pick the table and/or figure you need for the project at hand. At the end you are asked to recreate a page in \(\LaTeX\).

You have come a long way in programming \(\LaTeX\) and I am certain that by now you have the skills to approach this independently, but with the help from some walkthroughs and examples. Take a look at the LaTeX background.zip file on the course page and read the documents in the archive in the presented order.

So far the very brief intro. Have fun!


Exercise

  1. Study the figure documents in the LaTeX background.zip file.
  • The 0. GraphsFromRtoLaTeX.R file explains how to export graphs to lossless formats that tex can fully utilize.
  • The 1. ExampleFigure.tex document demonstrates implementation of figures in tex
  1. Study the table documents in the `LaTeX background.zip file.
  • The 0. Mori_Tables in LaTeX.pdf document is an in-depth guide to tables in tex
  • The 1. ExampleTable.tex and .pdf files takes the basics from the Mori document to demonstrate some straightforward implementation, resizing, placement and rotation of tables in tex
  • The 2. R-tables in LaTeX.R, .tex and .pdf files demonstrate how to conveniently export your data table in R to tex by means of the R-package xtable
  • The 3. Additional xtable_examples.tex and .pdf files display the code and realization of different tables that are generated with package xtable
  1. Use the following R-code
#load package lattice
library(lattice)
library(xtable)
#fix the random generator seed
set.seed(123)
#create data
data <- rnorm(1000)
#plot histogram
histogram(data)
#plot density 
densityplot(data^12 / data^10, xlab = expression(data^12/data^10))
#plot stripplot
stripplot(data^2, xlab = expression(data^2))
#plot boxplot
bwplot(exp(data))
#matrix with all data used
data.all <- cbind(data = data, 
                  squared1 = data^12 / data^10,
                  squared2 = data^2,
                  exponent = exp(data))

to generate the graphs that allow you to create the following page in \(\LaTeX\). The exercise is to recreate this page yourself:


HTML5 Icon

If the page does not render in your browser, please click this link


Upload the documents (at least the .tex and .pdf’s) to Surfdrive before the next meeting. I will post the solution to the exercise after the next lecture.