Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
R in Action, Second Edition.pdf
Скачиваний:
540
Добавлен:
26.03.2016
Размер:
20.33 Mб
Скачать

122

CHAPTER 6 Basic graphs

Treatment Outcome

Marked Improvement

Some Improvement

Figure 6.4 Horizontal

No Improvement

bar plot with tweaked

labels

0

10

20

30

40

The par() function allows you to make extensive modifications to the graphs that R produces by default. See chapter 3 for more details.

6.1.5Spinograms

Before finishing our discussion of bar plots, let’s take a look at a specialized version called a spinogram. In a spinogram, a stacked bar plot is rescaled so that the height of each bar is 1 and the segment heights represent proportions. Spinograms are created through the spine() function of the vcd package. The following code produces a simple spinogram:

library(vcd)

attach(Arthritis)

counts <- table(Treatment, Improved) spine(counts, main="Spinogram Example") detach(Arthritis)

The output is provided in

 

 

Spinogram Example

 

figure 6.5. The larger per-

Marked

 

 

 

 

 

 

 

 

 

 

centage

of

patients with

 

 

 

 

 

 

 

 

 

 

 

marked

improvement

in

 

 

 

 

 

 

the Treated

condition

is

Some

 

 

 

 

 

 

 

 

 

 

quite evident when com-

 

 

 

 

 

 

 

 

 

 

 

pared

with

the Placebo

 

 

 

 

 

 

condition.

 

 

Improved

 

 

 

 

 

 

 

 

 

 

 

 

pie charts are a popular

 

 

 

 

 

In addition to bar plots,

None

 

 

 

 

 

vehicle

for displaying the

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

distribution of a categori-

 

 

 

 

 

 

cal variable. We’ll consider

 

 

 

 

 

 

them next.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 6.5

Spinogram of arthritis

 

Placebo

 

 

Treated

 

 

treatment outcome

 

 

Treatment

 

1

0.8

0.6

0.4

0.2

0

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]