Contents


Aim

Short toy example to show hot to build a parent report with subreports (child reports) repeated on subsamples of the data within a loop. We first describe the Iris dataset. Then for each of the 4 variables measured we perform the same analysis and plots repeated. these analyses are performed in a subreport_child.Rmd file on the disc, compiled by the knitr function knit_child() and then inserted in the parent report/document. Then we continue with a few analyses/info on the main parent report (scatterplot matrix, Info Session).

Data used

Dataset for 3 Iris species (Iris virginica, Iris setosa, Iris versicolor) with 4 morphological variables measured :

Random sample :

  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
141 6.7 3.1 5.6 2.4 virginica
104 6.3 2.9 5.6 1.8 virginica
93 5.8 2.6 4 1.2 versicolor
19 5.7 3.8 1.7 0.3 setosa
24 5.1 3.3 1.7 0.5 setosa

Summary :

Sepal.Length Sepal.Width Petal.Length Petal.Width Species
Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100 setosa :50
1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300 versicolor:50
Median :5.800 Median :3.000 Median :4.350 Median :1.300 virginica :50
Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199 NA
3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800 NA
Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500 NA

Structure :

## 'data.frame':    150 obs. of  5 variables:
##  $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
##  $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
##  $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
##  $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
##  $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...

Description of each variable

Sepal.Length

The mean Sepal.Length is 5.8433333 cm.

Density

Boxplot

Data

Min. 1st Qu. Median Mean 3rd Qu. Max.
4.3 5.1 5.8 5.843 6.4 7.9

Sepal.Width

The mean Sepal.Width is 3.0573333 cm.

Density

Boxplot

Data

Min. 1st Qu. Median Mean 3rd Qu. Max.
2 2.8 3 3.057 3.3 4.4

Petal.Length

The mean Petal.Length is 3.758 cm.

Density

Boxplot

Data

Min. 1st Qu. Median Mean 3rd Qu. Max.
1 1.6 4.35 3.758 5.1 6.9

Petal.Width

The mean Petal.Width is 1.1993333 cm.

Density

Boxplot

Data

Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1 0.3 1.3 1.199 1.8 2.5

Scatterplots matrix

Session Info

## R version 3.2.5 (2016-04-14)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu precise (12.04.5 LTS)
## 
## locale:
##  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
##  [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=fr_BE.UTF-8   
##  [7] LC_PAPER=fr_BE.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
## [10] LC_TELEPHONE=C             LC_MEASUREMENT=fr_BE.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] pander_0.6.0 knitr_1.13  
## 
## loaded via a namespace (and not attached):
## [1] magrittr_1.5  formatR_1.4   tools_3.2.5   Rcpp_0.12.5   stringi_1.0-1 digest_0.6.9  stringr_1.0.0
## [8] evaluate_0.9