16

AN INTRODUCTION TO R

R> layout(matrix(1:2, nrow = 2)) R> hist(Forbes2000$marketvalue) R> hist(log(Forbes2000$marketvalue))

# Histogram of Forbes2000$marketvalue

Frequency

1000

0

0

50

100 150 200 250

300

350

Forbes2000$marketvalue

# Histogram of log(Forbes2000$marketvalue)

800

Frequency

400

0

−4

−2

02

4

6

log(Forbes2000$marketvalue)

Figure 1.1

Histograms of the market value and the logarithm of the market value for the companies contained in the Forbes 2000 list.

an R transcript file, for example analysis.R created with your favourite text editor, can be sourced into R using the source command

## R> source("analysis.R", echo = TRUE)

When all steps of a data analysis, i.e., data preprocessing, transformations, simple summary statistics and plots, model building and inference as well as reporting, are collected in such an R transcript file, the analysis can be reproduced at any time, maybe with modified data as it frequently happens in our consulting practice.