Examples for 'graphics::spineplot'


Spine Plots and Spinograms

Aliases: spineplot spineplot.default spineplot.formula

Keywords: hplot

### ** Examples

## treatment and improvement of patients with rheumatoid arthritis
treatment <- factor(rep(c(1, 2), c(43, 41)), levels = c(1, 2),
                    labels = c("placebo", "treated"))
improved <- factor(rep(c(1, 2, 3, 1, 2, 3), c(29, 7, 7, 13, 7, 21)),
                   levels = c(1, 2, 3),
                   labels = c("none", "some", "marked"))

## (dependence on a categorical variable)
(spineplot(improved ~ treatment))
plot of chunk example-graphics-spineplot-1
         improved
treatment none some marked
  placebo   29    7      7
  treated   13    7     21
## applications and admissions by department at UC Berkeley
## (two-way tables)
(spineplot(marginSums(UCBAdmissions, c(3, 2)),
           main = "Applications at UCB"))
plot of chunk example-graphics-spineplot-1
    Gender
Dept Male Female
   A  825    108
   B  560     25
   C  325    593
   D  417    375
   E  191    393
   F  373    341
(spineplot(marginSums(UCBAdmissions, c(3, 1)),
           main = "Admissions at UCB"))
plot of chunk example-graphics-spineplot-1
    Admit
Dept Admitted Rejected
   A      601      332
   B      370      215
   C      322      596
   D      269      523
   E      147      437
   F       46      668
## NASA space shuttle o-ring failures
fail <- factor(c(2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1,
                 1, 1, 1, 2, 1, 1, 1, 1, 1),
               levels = c(1, 2), labels = c("no", "yes"))
temperature <- c(53, 57, 58, 63, 66, 67, 67, 67, 68, 69, 70, 70,
                 70, 70, 72, 73, 75, 75, 76, 76, 78, 79, 81)

## (dependence on a numerical variable)
(spineplot(fail ~ temperature))
plot of chunk example-graphics-spineplot-1
           fail
temperature no yes
    [50,55]  0   1
    (55,60]  0   2
    (60,65]  0   1
    (65,70]  8   2
    (70,75]  3   1
    (75,80]  4   0
    (80,85]  1   0
(spineplot(fail ~ temperature, breaks = 3))
plot of chunk example-graphics-spineplot-1
           fail
temperature no yes
    [50,60]  0   3
    (60,70]  8   3
    (70,80]  7   1
    (80,90]  1   0
(spineplot(fail ~ temperature, breaks = quantile(temperature)))
plot of chunk example-graphics-spineplot-1
           fail
temperature no yes
    [53,67]  4   4
    (67,70]  4   2
    (70,75]  3   1
    (75,81]  5   0
## highlighting for failures
spineplot(fail ~ temperature, ylevels = 2:1)
plot of chunk example-graphics-spineplot-1

[Package graphics version 4.2.3 Index]