Category Archives: Graphical Methods

The dominion partitioner spinogram

library(vcd)
str(UKSoccer)
##  table [1:5, 1:5] 27 59 28 19 7 29 53 32 14 8 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ Home: chr [1:5] "0" "1" "2" "3" ...
##   ..$ Away: chr [1:5] "0" "1" "2" "3" ...
UKSoccer
##     Away
## Home  0  1  2  3  4
##    0 27 29 10  8  2
##    1 59 53 14 12  4
##    2 28 32 14 12  4
##    3 19 14  7  4  1
##    4  7  8 10  2  0
UKSoccer.trans <- margin.table(UKSoccer, 2:1)
spineplot(UKSoccer.trans)

plot of chunk unnamed-chunk-3

The stylish stripe graph

library(dplyr)
glimpse(faithful)
## Observations: 272
## Variables: 2
## $ eruptions (dbl) 3.600, 1.800, 3.333, 2.283, 4.533, 2.883, 4.700, 3.6...
## $ waiting   (dbl) 79, 54, 74, 62, 85, 55, 88, 85, 51, 85, 54, 84, 78, ...
head(faithful)
##   eruptions waiting
## 1     3.600      79
## 2     1.800      54
## 3     3.333      74
## 4     2.283      62
## 5     4.533      85
## 6     2.883      55
stripchart(faithful$eruptions, xlab="eruptions", pch="|")

plot of chunk unnamed-chunk-3

The companion density plot

library(dplyr)
glimpse(faithful)
## Observations: 272
## Variables: 2
## $ eruptions (dbl) 3.600, 1.800, 3.333, 2.283, 4.533, 2.883, 4.700, 3.6...
## $ waiting   (dbl) 79, 54, 74, 62, 85, 55, 88, 85, 51, 85, 54, 84, 78, ...
head(faithful)
##   eruptions waiting
## 1     3.600      79
## 2     1.800      54
## 3     3.333      74
## 4     2.283      62
## 5     4.533      85
## 6     2.883      55
d <- density(faithful$waiting) 
plot(d, main = "") 

plot of chunk unnamed-chunk-3

The ingenious box plot

library(vcd)
class(Arthritis)
## [1] "data.frame"
head(Arthritis)
##   ID Treatment  Sex Age Improved
## 1 57   Treated Male  27     Some
## 2 46   Treated Male  29     None
## 3 77   Treated Male  30     None
## 4 17   Treated Male  32   Marked
## 5 36   Treated Male  46   Marked
## 6 23   Treated Male  58   Marked
boxplot(Age ~ Improved, data=Arthritis, ylab="Age", xlab="Improved")

plot of chunk unnamed-chunk-3

The simple bar graph

library(vcdExtra)
class(Depends)
## [1] "table"
head(Depends)
## Depends
##    0    1    2    3    4    5 
##  986 1347  993  685  375  298
plot(Depends)

plot of chunk unnamed-chunk-3

The humble scatter plot

library(dplyr)
class(cars)
## [1] "data.frame"
glimpse(cars)
## Observations: 50
## Variables: 2
## $ speed (dbl) 4, 4, 7, 7, 8, 9, 10, 10, 10, 11, 11, 12, 12, 12, 12, 13...
## $ dist  (dbl) 2, 10, 4, 22, 16, 10, 18, 26, 34, 17, 28, 14, 20, 24, 28...
plot(cars)

plot of chunk unnamed-chunk-2

The story teller line graph

class(airmiles)
## [1] "ts"
head(airmiles)
## [1]  412  480  683 1052 1385 1418
plot(airmiles)

plot of chunk unnamed-chunk-1

The revealing stem and leaf chart

library(dplyr)
glimpse(beaver2)
## Observations: 100
## Variables: 4
## $ day   (dbl) 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 3...
## $ time  (dbl) 930, 940, 950, 1000, 1010, 1020, 1030, 1040, 1050, 1100,...
## $ temp  (dbl) 36.58, 36.73, 36.93, 37.15, 37.23, 37.24, 37.24, 36.90, ...
## $ activ (dbl) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
stem(beaver2$temp)
## 
##   The decimal point is 1 digit(s) to the left of the |
## 
##   364 | 8
##   366 | 3
##   368 | 90035577899
##   370 | 0114472223445577
##   372 | 34488
##   374 | 14661156
##   376 | 03444013456666678
##   378 | 1234446691255668
##   380 | 011122344670011557899
##   382 | 4455

The charming histogram

library(dplyr)
glimpse(faithful)
## Observations: 272
## Variables: 2
## $ eruptions (dbl) 3.600, 1.800, 3.333, 2.283, 4.533, 2.883, 4.700, 3.6...
## $ waiting   (dbl) 79, 54, 74, 62, 85, 55, 88, 85, 51, 85, 54, 84, 78, ...
hist(faithful$waiting, 
     xlab = "Waiting time", 
     main = "")

plot of chunk unnamed-chunk-2