Zum Inhalt springen

GNU R: Anwendungsbeispiele

Aus Wikibooks

In diesem Anhang finden sich Anwendungsbeispiele und -datensätze, die zum Testen der beschriebenen R-Funktionen dienen

Datenbeispiele

[Bearbeiten]

Beispiel 1

[Bearbeiten]
Geschlecht Alter Gewicht Groesse
m          28    80      170
w          18    55      174
w          25    74      183
m          29    101      190
m          21    84      185
w          19    74      178
w          27    65      169
w          26    56      163
m          31    88      189
m          22    78      184

R-Befehl zum Erzeugen dieser Tabelle:

w <- factor(c("m", "w", "w", "m", "m", "w", "w", "w", "m", "m"))
x <- c(28, 18, 25, 29, 21, 19, 27, 26, 31, 22)
y <- c(80, 55, 74, 101, 84, 74, 65, 56, 88, 78)
z <- c(170, 174, 183, 190, 185, 178, 169, 163, 189, 184)
bsp1 <- data.frame(w, x, y, z)
colnames(bsp1) <- c("Geschlecht", "Alter", "Gewicht", "Groesse")
rm(w, x, y, z)
bsp1

Beispiel 2

[Bearbeiten]
Geschlecht Note
m          2
w          1
m          5
m          3
w          4
m          3
w          2
w          2
w          1
m          3
m          1
w          4
m          2
w          1
m          4
m          3
w          5
m          2
w          1
w          2

R-Befehl zum Erzeugen dieser Tabelle:

x <- factor(c("m", "w", "m", "m", "w", "m", "w", "w", "w", "m", "m", "w", "m", "w", "m", "m", "w", "m", "w", "w"))
y <- c(2,1,5,3,4,3,2,2,1,3,1,4,2,1,4,3,5,2,1,2) 
bsp2 <- data.frame(x,y)
colnames(bsp2) <- c("Geschlecht", "Note")
rm(x,y)
bsp2

Beispiel 3

[Bearbeiten]
      Erfolg Abschlussnote
  1        0             5
  2        1             3
  3        1             2
  4        0             4
  5        1             1
  6        0             6
  7        1             3
  8        1             2
  9        0             4
 10        1             3
 11        0             6
 12        0             5
 13        0             4
 14        1             3

R-Befehl zum Erzeugen dieser Tabelle:

a <- factor(c(0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1))
b <- c(5, 3, 2, 4, 1, 6, 3, 2, 4, 3, 6, 5, 4, 3)
bsp3 <- data.frame(a,b)
colnames(bsp3) <- c("Erfolg", "Abschlussnote")
rm(a,b)
bsp3

Beispiel 4

[Bearbeiten]
    Name   Geschlecht Lieblingsfarbe Einkommen
1   Hans    maennlich          gruen      1233
2   Caro     weiblich           blau       800
3   Lars intersexuell           gelb      2400
4   Ines     weiblich        schwarz      4000
5 Samira     weiblich           gelb       899
6  Peter    maennlich          gruen      1100
7  Sarah     weiblich           blau      1900

R-Befehl zum Erzeugen dieser Tabelle:

w <- c("Hans","Caro","Lars","Ines","Samira","Peter","Sarah")
x <- factor(c("maennlich","weiblich","intersexuell","weiblich","weiblich","maennlich","weiblich"))
y <- factor(c("gruen","blau","gelb","schwarz","gelb","gruen","blau"))
z <- c(1233,800,2400,4000,899,1100,1900)
bsp4 <- data.frame(w,x,y,z)
colnames(bsp4) <- c("Name", "Geschlecht", "Lieblingsfarbe", "Einkommen")
rm(w,x,y,z)
bsp4


Beispiel 5

[Bearbeiten]
     Lebenstag Gewicht
1          1    3180
2          3    2960
3          6    3220
4         11    3270
5         12    3350
6         15    3410
7         19    3700
8         23    3830
9         28    4090
10        33    4310
11        35    4360
12        39    4520
13        47    4650
14        60    5310
15        66    5490
16        73    5540


R-Befehl zum Erzeugen dieser Tabelle:

x <- c(1, 3, 6, 11, 12, 15, 19, 23, 28, 33, 35, 39, 47, 60, 66, 73)
y <- c(3180, 2960, 3220, 3270, 3350, 3410, 3700, 3830, 4090, 4310, 4360, 4520, 4650, 5310, 5490, 5540)
bsp5 <- data.frame(x,y)
colnames(bsp5) <- c("Lebenstag", "Gewicht") 
rm(x,y)


Beispiel 6

[Bearbeiten]
   Person       Date Age Sex DimBody DimEmotion DimSelf DimFamily DimFriends DimSchool TotalScore
1  190053 2008-08-20  15   f   75.00      85.00   65.00     85.00      70.00     90.00      78.33
2  190050 2008-01-24  16   m   80.00      80.00   75.00     65.00      70.00     60.00      71.67
3  190052 2008-02-05  11   m   70.00      65.00   35.00     80.00      45.00     95.00      65.00
4  190002 2006-12-07  11   f   85.00      90.00   85.00     70.00      80.00     55.00      77.50
5  190002 2008-01-31  13   f   75.00      90.00   75.00     55.00      85.00     70.00      75.00
6  190005 2007-02-22  12   m   65.00      90.00   70.00     95.00      75.00     65.00      76.67
7  190035 2007-05-22  14   f   60.00      85.00   65.00     75.00      80.00     55.00      70.00
8  190021 2006-08-30  16   f   55.00      50.00   50.00     30.00      55.00     55.00      49.17
9  190014 2006-12-07  12   m   75.00      90.00   40.00     85.00      75.00     60.00      70.83
10 190029 2006-11-21  13   f   55.00      70.00   60.00     65.00      85.00     55.00      65.00
11 190025 2006-12-07  12   f  100.00      95.00   95.00    100.00      90.00     85.00      94.17
12 190025 2007-02-20  13   f   85.00      95.00   85.00     85.00      95.00     75.00      86.67
13 190036 2007-06-05  12   m   55.00      75.00   80.00     85.00      90.00     75.00      76.67
14 190031 2007-02-13  13   f   60.00      80.00   60.00     80.00      90.00     55.00      70.83
15 190034 2007-05-19  16   f   50.00      55.00   45.00     80.00      70.00     30.00      55.00
16 190044 2007-10-23  13   m   75.00      65.00   60.00     85.00      60.00     75.00      70.00
17 190041 2007-08-16  16   f   90.00      90.00   90.00    100.00      70.00     60.00      83.33
18 190046 2007-11-15  14   f   70.00      75.00   90.00     70.00      80.00     75.00      76.67
19 190034 2007-07-19  16   f   50.00      60.00   45.00     90.00      75.00     55.00      62.50
20 191028 2006-10-26   7   f   66.67     100.00  100.00     66.67      50.00     83.33      77.78
21 191035 2007-05-22   6   f   66.67      83.33   66.67    100.00     100.00    100.00      86.11
22 191037 2007-05-31   6   m   66.67      83.33  100.00     83.33      66.67     83.33      80.56
23 191036 2007-06-19   6   f  100.00      83.33  100.00     83.33      83.33     66.67      86.11
24 192052 2008-02-05   8   f   80.00      60.00   60.00     80.00      75.00     65.00      70.00
25 190028 2006-10-26   9   f   65.00      65.00   60.00     80.00      75.00     75.00      70.00
26 190028 2008-02-15  11   f   85.00      90.00   70.00     95.00      90.00     90.00      86.67
27 191028 2008-02-16   9   f   80.00      95.00  100.00     95.00      80.00     85.00      89.17
28 190039 2007-05-29   9   f   70.00      90.00   80.00     95.00      90.00     95.00      86.67
29 190037 2007-05-31   8   m   90.00      75.00   60.00    100.00      90.00     80.00      82.50
30 191030 2007-02-22   9   f   80.00      75.00   60.00     85.00      85.00     60.00      74.17
31 192030 2007-02-22   8   m   85.00      95.00   60.00     85.00      60.00     80.00      77.50
32 190030 2007-02-22  11   f   70.00      90.00   60.00     65.00      80.00     55.00      70.00
33 190022 2006-05-07  10   m   95.00      95.00   80.00     85.00      50.00     65.00      78.33
34 190048 2008-01-08  11   f   65.00      75.00   60.00     85.00      70.00     60.00      69.17
35 190017 2007-12-18   8   f   40.00      80.00   70.00     60.00      55.00     75.00      63.33
36 190015 2006-11-28  12   f   60.00      60.00   60.00     75.00      90.00     80.00      70.83
37 191002 2008-01-31   9   f   80.00     100.00   90.00     70.00      95.00     65.00      83.33
38 271050 2008-01-31  13   m   85.00      65.00   70.00     70.00      70.00     70.00      71.67
39 270050 2008-01-31  16   m   55.00      60.00   60.00     55.00      70.00     50.00      58.33
40 270052 2008-02-05  11   m   40.00      45.00   55.00     65.00      40.00     65.00      51.67
41 271052 2008-02-05  10   m   85.00      45.00   40.00     70.00      50.00     55.00      57.50
42 272052 2008-02-05   8   f   60.00      55.00   70.00     70.00      80.00     75.00      68.33
43 271002 2007-02-22   8   f   80.00      65.00   65.00     75.00      40.00     60.00      64.17
44 271002 2007-01-26   8   f   85.00      80.00   80.00     75.00      80.00     90.00      81.67
45 270002 2007-01-26  12   f   75.00      85.00   90.00     70.00      95.00     75.00      81.67
46 271002 2008-01-31   9   f   60.00      60.00   65.00     60.00      70.00     75.00      65.00
47 270002 2008-01-31  13   f   80.00      70.00   90.00     70.00      85.00     80.00      79.17
48 270005 2007-01-23  12   m   65.00      45.00   45.00     45.00      50.00     60.00      51.67
49 270005 2007-01-23  12   m   65.00      55.00   45.00     35.00      55.00     55.00      51.67
50 270010 2007-05-22   9   f   70.00      65.00   75.00     90.00      50.00     95.00      74.17
51 270014 2007-04-18  13   m   75.00      65.00   50.00     65.00      30.00     65.00      58.33
52 270022 2006-12-07  10   m   85.00      90.00   75.00    100.00      55.00     70.00      79.17
53 270025 2006-11-30  12   f  100.00      80.00   80.00     85.00      95.00     95.00      89.17
54 270025 2007-02-20  13   f   90.00      95.00   80.00     80.00      95.00     95.00      89.17
55 270028 2006-10-26   9   f   55.00      65.00   60.00     45.00      50.00     35.00      51.67
56 270028 2008-02-16  11   f   55.00      45.00   50.00     50.00      50.00     55.00      50.83
57 270029 2006-11-21  13   f   70.00      50.00   70.00     50.00      85.00     80.00      67.50
58 271030 2006-12-14   9   f   35.00      65.00   60.00     55.00      75.00     45.00      55.83
59 270030 2006-12-14  11   f   60.00      55.00   35.00     60.00      60.00     55.00      54.17
60 270035 2007-05-22  14   f   60.00      60.00   55.00     65.00      90.00     55.00      64.17
61 270036 2007-06-05  12   m   80.00      60.00   65.00     80.00      70.00     85.00      73.33
62 270036 2007-06-19  12   m   60.00      55.00   75.00     75.00      65.00     85.00      69.17
63 270037 2007-05-31   8   m   80.00      90.00   75.00     85.00      95.00     85.00      85.00
64 270039 2007-05-29   9   f   45.00      80.00   70.00     90.00      95.00     85.00      77.50
65 270041 2007-08-16  16   f   85.00      95.00   75.00     75.00      90.00     70.00      81.67
66 270044 2007-10-23  13   m   60.00      65.00   55.00     75.00      55.00     50.00      60.00
67 270046 2007-11-15  14   f   60.00      70.00   65.00     80.00      60.00     80.00      69.17
68 270048 2008-01-08  11   f   60.00      60.00   55.00     80.00      75.00     50.00      63.33
69 270002 2007-02-22  12   f   70.00      75.00   65.00     55.00      75.00     60.00      66.67
70 270004 2006-11-25  14   f   90.00     100.00  100.00     95.00      85.00    100.00      95.00
71 270017 2007-12-13   8   f   60.00      80.00   65.00     85.00      50.00     80.00      70.00
72 271028 2008-02-16   9   f   95.00      75.00   75.00     70.00      80.00     75.00      78.33
73 270015 2006-11-28  12   f   85.00      90.00   85.00     75.00      85.00     95.00      85.83
74 271036 2007-06-19   6   f   85.00      85.00   80.00     60.00      95.00     80.00      80.83
75 270045 2007-10-23   7   m   75.00      80.00   55.00     70.00      60.00     75.00      69.17
76 270040 2007-08-07   5   f   90.00      70.00   75.00     75.00      65.00     70.00      74.17
77 271037 2007-05-31   6   m   80.00      90.00   80.00     95.00      80.00     55.00      80.00
78 271035 2007-05-22   7   f   80.00     100.00   85.00     80.00      75.00     75.00      82.50
79 271010 2007-05-22   6   m  100.00      65.00   70.00     90.00      75.00     80.00      80.00
80 270033 2007-03-22   4   m   80.00      80.00   90.00     75.00      75.00     65.00      77.50
81 271036 2007-06-05   7   f   60.00      80.00   70.00     85.00      85.00     65.00      74.17
82 271028 2006-10-26   7   f   95.00      85.00   80.00     90.00      70.00     65.00      80.83


R-Befehl zur Erzeugung des Datensatzes:

bsp6 <- structure(list(Person = c("190053", "190050", "190052", "190002", "190002", "190005", 
    "190035", "190021", "190014", "190029", "190025", "190025", "190036", "190031", "190034", 
    "190044", "190041", "190046", "190034", "191028", "191035", "191037", "191036", "192052", 
    "190028", "190028", "191028", "190039", "190037", "191030", "192030", "190030", "190022", 
    "190048", "190017", "190015", "191002", "271050", "270050", "270052", "271052", "272052", 
    "271002", "271002", "270002", "271002", "270002", "270005", "270005", "270010", "270014", 
    "270022", "270025", "270025", "270028", "270028", "270029", "271030", "270030", "270035", 
    "270036", "270036", "270037", "270039", "270041", "270044", "270046", "270048", "270002", 
    "270004", "270017", "271028", "270015", "271036", "270045", "270040", "271037", "271035", 
    "271010", "270033", "271036", "271028"), Date = structure(c(1219183200,  1201129200, 
    1202166000, 1165446000, 1201734000, 1172098800, 1179784800,  1156888800, 1165446000, 
    1164063600, 1165446000, 1171926000, 1180994400,  1171321200, 1179525600, 1193090400, 
    1187215200, 1195081200, 1184796000,  1161813600, 1179784800, 1180562400, 1182204000, 
    1202166000, 1161813600,  1203030000, 1203116400, 1180389600, 1180562400, 1172098800, 
    1172098800,  1172098800, 1146952800, 1199746800, 1197932400, 1164668400, 1201734000,  
    1201734000, 1201734000, 1202166000, 1202166000, 1202166000, 1172098800,  1169766000, 
    1169766000, 1201734000, 1201734000, 1169506800, 1169506800,  1179784800, 1176847200, 
    1165446000, 1164841200, 1171926000, 1161813600,  1203116400, 1164063600, 1166050800, 
    1166050800, 1179784800, 1180994400,  1182204000, 1180562400, 1180389600, 1187215200, 
    1193090400, 1195081200,  1199746800, 1172098800, 1164409200, 1197500400, 1203116400, 
    1164668400,  1182204000, 1193090400, 1186437600, 1180562400, 1179784800, 1179784800,  
    1174518000, 1180994400, 1161813600), class = c("POSIXt", "POSIXct" ), tzone = ""), 
    Age = c(15, 16, 11, 11, 13, 12, 14, 16, 12,  13, 12, 13, 12, 13, 16, 13, 16, 14, 16, 7, 6, 
    6, 6, 8, 9, 11,  9, 9, 8, 9, 8, 11, 10, 11, 8, 12, 9, 13, 16, 11, 10, 8, 8, 8,  12, 9, 13, 
    12, 12, 9, 13, 10, 12, 13, 9, 11, 13, 9, 11, 14, 12,  12, 8, 9, 16, 13, 14, 11, 12, 14, 8, 
    9, 12, 6, 7, 5, 6, 7, 6,  4, 7, 7), Sex = structure(c(1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 
    1L, 1L, 1L, 2L,  1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,  1L, 2L, 
    1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,  1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 2L,  2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L,  
    1L, 2L, 2L, 1L, 1L), .Label = c("f", "m"), class = "factor"), DimBody = c(75, 80, 70, 85, 
    75,  65, 60, 55, 75, 55, 100, 85, 55, 60, 50, 75, 90, 70, 50, 66.67,  66.67, 66.67, 100, 80, 
    65, 85, 80, 70, 90, 80, 85, 70, 95, 65,  40, 60, 80, 85, 55, 40, 85, 60, 80, 85, 75, 60, 80, 
    65, 65, 70,  75, 85, 100, 90, 55, 55, 70, 35, 60, 60, 80, 60, 80, 45, 85,  60, 60, 60, 70, 
    90, 60, 95, 85, 85, 75, 90, 80, 80, 100, 80,  60, 95), DimEmotion = c(85, 80, 65, 90, 90, 
    90, 85, 50,  90, 70, 95, 95, 75, 80, 55, 65, 90, 75, 60, 100, 83.33, 83.33,  83.33, 60, 65, 
    90, 95, 90, 75, 75, 95, 90, 95, 75, 80, 60, 100,  65, 60, 45, 45, 55, 65, 80, 85, 60, 70, 
    45, 55, 65, 65, 90, 80,  95, 65, 45, 50, 65, 55, 60, 60, 55, 90, 80, 95, 65, 70, 60, 75,  
    100, 80, 75, 90, 85, 80, 70, 90, 100, 65, 80, 80, 85), DimSelf = c(65,  75, 35, 85, 75, 70, 
    65, 50, 40, 60, 95, 85, 80, 60, 45, 60, 90,  90, 45, 100, 66.67, 100, 100, 60, 60, 70, 100, 
    80, 60, 60, 60,  60, 80, 60, 70, 60, 90, 70, 60, 55, 40, 70, 65, 80, 90, 65, 90,  45, 45, 
    75, 50, 75, 80, 80, 60, 50, 70, 60, 35, 55, 65, 75, 75,  70, 75, 55, 65, 55, 65, 100, 65, 
    75, 85, 80, 55, 75, 80, 85,  70, 90, 70, 80), DimFamilie = c(85, 65, 80, 70, 55, 95,  75, 
    30, 85, 65, 100, 85, 85, 80, 80, 85, 100, 70, 90, 66.67,  100, 83.33, 83.33, 80, 80, 95, 95, 
    95, 100, 85, 85, 65, 85, 85,  60, 75, 70, 70, 55, 65, 70, 70, 75, 75, 70, 60, 70, 45, 35, 
    90,  65, 100, 85, 80, 45, 50, 50, 55, 60, 65, 80, 75, 85, 90, 75,  75, 80, 80, 55, 95, 85, 
    70, 75, 60, 70, 75, 95, 80, 90, 75, 85,  90), DimFriends = c(70, 70, 45, 80, 85, 75, 80, 55, 
    75,  85, 90, 95, 90, 90, 70, 60, 70, 80, 75, 50, 100, 66.67, 83.33,  75, 75, 90, 80, 90, 90, 
    85, 60, 80, 50, 70, 55, 90, 95, 70, 70,  40, 50, 80, 40, 80, 95, 70, 85, 50, 55, 50, 30, 55, 
    95, 95, 50,  50, 85, 75, 60, 90, 70, 65, 95, 95, 90, 55, 60, 75, 75, 85, 50,  80, 85, 95, 
    60, 65, 80, 75, 75, 75, 85, 70), DimSchool = c(90,  60, 95, 55, 70, 65, 55, 55, 60, 55, 85, 
    75, 75, 55, 30, 75, 60,  75, 55, 83.33, 100, 83.33, 66.67, 65, 75, 90, 85, 95, 80, 60,  80, 
    55, 65, 60, 75, 80, 65, 70, 50, 65, 55, 75, 60, 90, 75, 75,  80, 60, 55, 95, 65, 70, 95, 95, 
    35, 55, 80, 45, 55, 55, 85, 85,  85, 85, 70, 50, 80, 50, 60, 100, 80, 75, 95, 80, 75, 70, 
    55,  75, 80, 65, 65, 65), TotalScore = c(78.33, 71.67, 65, 77.5,  75, 76.67, 70, 49.17, 
    70.83, 65, 94.17, 86.67, 76.67, 70.83,  55, 70, 83.33, 76.67, 62.5, 77.78, 86.11, 80.56, 
    86.11, 70, 70,  86.67, 89.17, 86.67, 82.5, 74.17, 77.5, 70, 78.33, 69.17, 63.33,  70.83, 
    83.33, 71.67, 58.33, 51.67, 57.5, 68.33, 64.17, 81.67,  81.67, 65, 79.17, 51.67, 51.67, 
    74.17, 58.33, 79.17, 89.17, 89.17,  51.67, 50.83, 67.5, 55.83, 54.17, 64.17, 73.33, 69.17, 
    85, 77.5,  81.67, 60, 69.17, 63.33, 66.67, 95, 70, 78.33, 85.83, 80.83,  69.17, 74.17, 80, 
    82.5, 80, 77.5, 74.17, 80.83)), .Names = c("Person",  "Date", "Age", "Sex", "DimBody", 
    "DimEmotion",  "DimSelf", "DimFamily", "DimFriends", "DimSchool",  "TotalScore"), row.names 
    = c(NA, -82L), class = "data.frame")


Beispiel 7

[Bearbeiten]

Die Ergebnisse eines Hochsprungwettbewerbs lauten wie folgt.

  • 0 bedeutet, dass die entsprechende Höhe nicht übersprungen wurde
  • 1 bedeutet, dass die entsprechende Höhe übersprungen wurde
          1.00 1.10 1.20 1.30 1.50 1.60 1.70 1.90 2.00 2.20
Hans         1    1    1    1    1    1    1    1    1    1
Karola       1    1    1    1    1    1    1    1    1    0
Matthias     1    1    1    1    1    1    1    1    0    0
Stefan       1    1    1    1    1    1    1    0    0    0
Sabine       1    1    1    1    1    1    1    0    0    0
Irma         1    1    1    1    1    1    0    0    0    0
Heike        1    1    1    1    1    1    0    0    0    0
Ralf         1    1    1    1    1    1    0    0    0    0
Rainer       1    1    1    1    1    0    0    0    0    0
Simon        1    1    1    1    1    0    0    0    0    0
Andreas      1    1    1    1    1    0    0    0    0    0
Elke         1    1    1    1    0    0    0    0    0    0
Gabi         1    1    1    1    0    0    0    0    0    0
David        1    1    1    1    0    0    0    0    0    0
Jonas        1    1    1    1    0    0    0    0    0    0
Nicklas      1    1    1    1    0    0    0    0    0    0
Sandra       1    1    1    0    0    0    0    0    0    0
Mario        1    1    1    0    0    0    0    0    0    0
Guido        1    1    1    0    0    0    0    0    0    0
Lisa         1    1    1    0    0    0    0    0    0    0
Peter        1    1    1    0    0    0    0    0    0    0
Justus       1    1    1    0    0    0    0    0    0    0
Josef        1    1    1    0    0    0    0    0    0    0
Brigitte     1    1    1    0    0    0    0    0    0    0
Kevin        1    1    0    0    0    0    0    0    0    0
Marcel       1    1    0    0    0    0    0    0    0    0
Nadine       1    1    0    0    0    0    0    0    0    0
Alex         1    1    0    0    0    0    0    0    0    0
Katharina    1    1    0    0    0    0    0    0    0    0
Daniel       1    1    0    0    0    0    0    0    0    0
Jens         1    1    0    0    0    0    0    0    0    0
Dieter       1    0    0    0    0    0    0    0    0    0
Sebastian    1    0    0    0    0    0    0    0    0    0
Anne         1    0    0    0    0    0    0    0    0    0

Diese Tabelle wird wie folgt erzeugt:

hochsprung <- structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1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c("Hans", "Karola",
"Matthias", "Stefan", "Sabine", "Irma",      "Heike", "Ralf", "Rainer", "Simon", "Andreas", "Elke", "Gabi", "David",
"Jonas", "Nicklas", "Sandra", "Mario", "Guido",      "Lisa", "Peter", "Justus", "Josef", "Brigitte", "Kevin", "Marcel",
"Nadine", "Alex", "Katharina", "Daniel", "Jens",      "Dieter", "Sebastian", "Anne"), c("1.00", "1.10", "1.20", "1.30",
"1.50", "1.60", "1.70", "1.90", "2.00", "2.20")))


Beispiel 8

[Bearbeiten]

Die Ergebnisse eines Minigolfwettbewerbs lauten wie folgt.

  • 0 bedeutet, dass das entsprechende Loch nicht mit einem Schlag getroffen wurde
  • 1 bedeutet, dass das entsprechende Loch mit einem Schlag getroffen wurde
          Loch1 Loch2 Loch3 Loch4 Loch5 Loch6 Loch7 Loch8 Loch9 Loch10
Hans          0     1     1     0     1     1     0     1     1      1
Karola        1     0     1     1     1     0     1     1     1      0
Matthias      1     1     1     0     1     1     1     1     0      0
Stefan        0     0     1     1     0     1     1     0     0      1
Sabine        1     1     1     1     1     1     1     0     0      0
Irma          1     1     0     1     1     1     0     1     0      0
Heike         1     0     1     0     1     1     0     0     0      1
Ralf          1     1     1     0     1     1     0     0     0      0
Rainer        1     1     0     1     1     0     0     1     0      1
Simon         1     0     1     1     1     0     1     0     1      0
Andreas       1     1     1     0     1     0     0     0     0      0
Elke          1     1     0     1     0     1     0     0     1      0
Gabi          0     1     1     1     0     0     1     0     0      1
David         1     1     0     1     0     0     0     0     0      0
Jonas         1     1     0     1     1     0     1     1     0      0
Nicklas       1     1     1     1     0     1     0     0     1      0
Sandra        0     1     0     0     1     0     1     1     0      1
Mario         1     0     1     0     1     1     0     0     0      0
Guido         1     1     1     0     0     0     0     0     1      0
Lisa          0     1     1     0     0     0     1     0     0      0
Peter         1     0     1     0     1     0     0     0     1      0
Justus        1     1     1     0     0     0     1     0     0      1
Josef         1     0     1     0     0     0     0     0     0      0
Brigitte      1     1     1     0     0     0     1     0     1      0
Kevin         0     1     0     0     1     0     0     1     0      1
Marcel        1     1     0     0     0     0     0     0     0      0
Nadine        1     0     0     1     0     1     0     0     1      0
Alex          1     0     0     0     0     0     0     0     0      0
Katharina     0     1     0     0     0     1     1     0     1      1
Daniel        1     1     0     0     0     0     0     0     0      0
Jens          1     1     0     1     0     0     1     0     1      0
Dieter        1     0     0     0     0     0     1     1     0      0
Sebastian     1     0     1     0     1     0     0     0     1      1
Anne          0     0     0     0     1     0     1     0     0      1

Diese Tabelle wird wie folgt erzeugt:

minigolf <- structure(list(Loch1 = c(0, 1, 1, 0, 1, 1, 1, 1, 1,  1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0,  
1, 1, 1, 0, 1, 1, 1, 1, 0), Loch2 = c(1, 0, 1, 0,  1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,  0, 1, 0, 1, 1, 
1, 0, 0, 1, 1, 1, 0, 0, 0), Loch3 = c(1,  1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0,  1, 1, 1, 1, 1, 1, 1, 0, 
0, 0, 0, 0, 0, 0, 0, 1,  0), Loch4 = c(0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1,  1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 1, 0,  0, 0, 1, 0, 0, 0), Loch5 = c(1, 1, 1, 0, 1, 1, 1,  1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0,  0, 1, 
0, 0, 0, 0, 0, 0, 0, 1, 1), Loch6 = c(1, 0,  1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1,  0, 0, 0, 0, 0, 0, 0, 
0, 1, 0, 1, 0, 0, 0, 0, 0 ), Loch7 = c(0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0,  1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 
0, 0, 0,  1, 0, 1, 1, 0, 1), Loch8 = c(1, 1, 1, 0, 0, 1, 0,  0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,  0, 1, 
0, 0, 0, 0, 0, 0, 1, 0, 0), Loch9 = c(1, 1,  0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0,  1, 0, 1, 0, 0, 1, 0, 0, 
1, 0, 1, 0, 1, 0, 1, 0 ), Loch10 = c(1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0,  1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
0,  1, 0, 0, 0, 1, 1)), .Names = c("Loch1", "Loch2", "Loch3",  "Loch4", "Loch5", "Loch6", "Loch7", "Loch8", "Loch9", 
"Loch10" ), class = "data.frame", row.names = c("Hans", "Karola", "Matthias",  "Stefan", "Sabine", "Irma", "Heike",
"Ralf", "Rainer", "Simon",  "Andreas", "Elke", "Gabi", "David", "Jonas", "Nicklas", "Sandra",  "Mario", "Guido",
"Lisa", "Peter", "Justus", "Josef", "Brigitte",  "Kevin", "Marcel", "Nadine", "Alex", "Katharina", "Daniel", "Jens",
"Dieter", "Sebastian", "Anne"))

Beispiel 9

[Bearbeiten]

Ein Fragebogen besteht aus 27 Fragen, welche die Antworten "nie / selten / manchmal / oft / immer" zulassen. Die Antworten werden wie folgt codiert:

  • 1 = nie
  • 2 = selten
  • 3 = manchmal
  • 4 = oft
  • 5 = immer

Der Fragebogen wird nun von 122 Personen ausgefüllt. Da dieser Datensatz relativ groß ist, wird auf eine Darstellung der Tabelle verzichtet. Der Code zum Erzeugen des Datensatzes lautet:

bsp9 <- structure(list(Frage1 = c(4, 4, 5, 5, 5, 1, 3, 3, 3, 3, 5, 5,  5, 3, 3, 4, 5, 4, 3, 2, 2, 2, 3, 4, 3, 4, 4, 2, 
5, 5, 5, 5, 5,  5, 1, 3, 4, 3, 3, 4, 3, 3, 3, 3, 5, 3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, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), 
Frage26 = c(4,  2, 5, 5, 5, 1, 5, 4, 3, 5, 5, 5, 5, 5, 5, 4, 4, 5, 5, 2, 2, 2,  4, 5, 4, 4, 3, 5, 5, 5, 5, 5, 3, 5, 3, 5, 5, 
3, 3, 3, 2, 3, 3,  4, 4, 5, 2, 5, 3, 4, 5, 4, 3, 3, 4, 4, 4, 5, 3, 3, 3, 3, 3, 3,  3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
4, 4, 5, 1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3,  3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 
5, 5, 5), Frage27 = c(2,  5, 2, 4, 4, 4, 3, 1, 3, 5, 5, 5, 5, 4, 3, 4, 2, 2, 3, 3, 2, 2,  3, 4, 3, 5, 5, 4, 5, 3, 1, 3, 1, 2, 
2, 4, 5, 4, 4, 3, 5, 4, 3,  4, 5, 5, 3, 5, 3, 4, 5, 4, 3, 5, 4, 4, 5, 5, 3, 3, 3, 3, 3, 3,  3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 
4, 4, 4, 4, 4, 5, 1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3,  3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 
5, 5, 5, 5, 5, 5)), .Names = c("Frage1",  "Frage2", "Frage3", "Frage4", "Frage5", "Frage6", "Frage7", "Frage8",  "Frage9", 
"Frage10", "Frage11", "Frage12", "Frage13", "Frage14",  "Frage15", "Frage16", "Frage17", "Frage18", "Frage19", "Frage20",  
"Frage21", "Frage22", "Frage23", "Frage24", "Frage25", "Frage26",  "Frage27"), row.names = c(NA, 122L), class = "data.frame", 
na.action = structure(123:231, .Names = c("38",  "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49",  "50", "51",
"52", "53", "54", "55", "56", "57", "58", "59", "60",  "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71",  "72", 
"73", "74", "75", "76", "77", "78", "79", "80", "81", "82",  "158", "159", "160", "161", "162", "163", "164", "165", "166",  
"167", "168", "169", "170", "171", "172", "173", "174", "175",  "176", "177", "178", "179", "180", "181", "182", "183", "184", 
 "185", "186", "187", "188", "189", "190", "191", "192", "193",  "194", "195", "196", "197", "198", "199", "200", "201", 
"202",  "203", "204", "205", "206", "207", "208", "209", "210", "211",  "212", "213", "214", "215", "216", "217", "218", "219",
"220",  "221"), class = "omit"))


Beispiel 10

[Bearbeiten]

In einer Untersuchung wurde bei Kinder (Self) und deren Eltern (Proxy) bestimmte Werte über die Kinder abgefragt. Die Kinder schätzten sich also zunächst selber ein, anschließend haben die Eltern ihre Kinder eingeschätzt. Zusätzlich existieren zu jedem Item Normwerte (Norm), die den deutschen Durchschnitt widerspiegeln.

bsp10 <-  structure(list(Case = c("1", "1", "1", "1", "1", "1", "2", "2",  "2", "2", "2", "2", "3", "3", "3", "3", "3", "3", "6", "6", "6",  "6", "6", "6", "8", "8", "8", "8", "8", "8", "87", "87", "87",  "87", "87", "87", "97", "97", "97", "97", "97", "97", "3", "3",  "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "4", "4", "4",  "4", "4", "4", "5", "5", "5", "5", "5", "5", "6", "6", "6", "6",  "6", "6", "8", "8", "8", "8", "8", "8", "87", "87", "87", "87",  "87", "87", "97", "97", "97", "97", "97", "97", "Norm", "Norm",  "Norm", "Norm", "Norm", "Norm", "Norm", "Norm", "Norm", "Norm",  "Norm", "Norm"), Item = structure(c(2L, 3L, 4L, 5L, 6L, 7L, 2L,  3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L, 5L, 6L,  7L, 2L, 3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L,  5L, 6L, 7L, 2L, 3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L, 5L, 6L, 7L, 2L,  3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L, 5L, 6L,  7L, 2L, 3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L,  5L, 6L, 7L, 2L, 3L, 4L, 5L, 6L, 7L, 2L, 3L, 4L, 5L, 6L, 7L), .Label = c("Item",  "Body", "Emotion", "Family", "Friends", "School", "Index"), class = "factor"),      Score = c(73.201612015845, 59.5103286592648, 51.211152156733,      57.8338409160427, 62.8406196084782, 59.8493862271105, 64.2956371038732,      43.2100676781528, 45.2472845564316, 53.2323487558682, 48.0853674487552,      59.8493862271105, 47.0820037411972, 50.611904867224, 38.3277278491481,      33.7624512920086, 42.9406488823006, 44.4784623272101, 49.6265680017606,      37.86511552469, 46.5337891235228, 57.8338409160427, 34.8124918251294,      42.2729427242036, 55.6028554137324, 44.7951224546969, 53.2511808274062,      49.7945287460269, 51.0750344123124, 48.2897549745108, 64.2956371038732,      46.5276241871987, 49.4651816728235, 46.928570478635, 51.0750344123124,      48.2897549745108, 64.2956371038732, 43.2100676781528, 47.9305655106504,      49.7945287460269, 54.4010389092698, 53.1070741073933, 52.679424728785,      40.0684105152636, 59.0810578447264, 9.28427673577973, 41.2400158442848,      40.2047327317923, 49.5401073855047, 44.2682553036083, 56.0092601714117,      9.28427673577973, 41.2400158442848, 41.7118474878159, 71.2257238675,      63.0762558775002, 49.1044321652144, 59.6677528939964, 63.6827432674325,      66.246501340745, 59.3808825999571, 49.3745883304313, 45.4684267559846,      52.5916164348338, 55.4046058734162, 52.6531091581688, 43.6611274898783,      34.6555670768689, 43.7937149049355, 59.6677528939964, 32.9468364077597,      34.7243154371611, 34.770256416197, 40.0684105152636, 53.4121134505333,      34.1372899040197, 51.4234786227506, 41.7118474878159, 55.8940393515167,      38.1771760608847, 42.1816928023213, 52.5916164348338, 47.6930520805652,      38.7563367324969, 49.5401073855047, 44.2682553036083, 42.1816928023213,      45.9407404477103, 35.348549195, 38.7563367324969, 75.22,      81.23, 79.16, 78.54, 72.52, 77.73, 74.36, 78.52, 79.77, 70.39,      72.07, 77.14), Number = structure(c(1L, 1L, 1L, 1L, 1L, 1L,      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,      2L, 2L, 2L, 2L, 2L, 2L), .Label = c("First", "Norm"), class = "factor"),      Proxy = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,      2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,      2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,      2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,      1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L,      4L, 4L), .Label = c("Proxy", "Self", "SelfNorm", "ProxyNorm"     ), class = "factor")), .Names = c("Case", "Item", "Score",  "Number", "Proxy"), row.names = 2:103, class = "data.frame")1> 

Grafikbeispiele

[Bearbeiten]

Die hier verwendeten Grafiken stammen von  Benutzer Thire und sollen die Themen des Kapitels GNU R: Diagramme veranschaulichen.

Grafikbeispiel 1

[Bearbeiten]

Quelltext:

class=c(0,18.5,25,30,35,40,100)
cols=c("skyblue4","darkgreen","yellow","orange","red","darkred","black")
gr=seq(1.4,2.2,length=100)

bmi.k<-function(groesse,konstant) {
  return(groesse^2*konstant)
}

png(filename="BodyMassIndex.png", width=1024, height=768, pointsize=12) 
par(bg="whitesmoke")
plot(gr,bmi.k(gr,18),type="n",xlim=c(1.60,1.99),ylim=c(40,125),xaxt="n",yaxt="n",cex.axis=1.4,cex.lab=1.3,cex.main=1.7,xlab="Größe [in m]",ylab="Gewicht [in kg]", main="Body Mass Index")
polygon(c(gr,rev(gr)),c(bmi.k(gr,class[1]),rev(bmi.k(gr,class[2]))),col=cols[1])
polygon(c(gr,rev(gr)),c(bmi.k(gr,class[2]),rev(bmi.k(gr,class[3]))),col=cols[2])
polygon(c(gr,rev(gr)),c(bmi.k(gr,class[3]),rev(bmi.k(gr,class[4]))),col=cols[3])
polygon(c(gr,rev(gr)),c(bmi.k(gr,class[4]),rev(bmi.k(gr,class[5]))),col=cols[4])
polygon(c(gr,rev(gr)),c(bmi.k(gr,class[5]),rev(bmi.k(gr,class[6]))),col=cols[5])
polygon(c(gr,rev(gr)),c(bmi.k(gr,class[6]),rev(bmi.k(gr,class[7]))),col=cols[6])
polygon(c(gr,rev(gr)),c(bmi.k(gr,class[7]),rev(bmi.k(gr,class[8]))),col=cols[7]) 

box()
grid(lty="dotdash",col="darkgrey")
abline(v=seq(1.65,1.95,by=0.1),h=seq(50,110,by=20),lty="dotted",col="grey") 

legend(x="bottomright",inset=0.005,legend=c("Untergewicht","Normalgewicht","Präadipositas","Adipositas Grad I","Adipositas Grad II","Adipositas Grad III"),col=cols,lwd=6,bg="skyblue")
axis(1,at=format(seq(1.60,2,by=0.1),nsmall=2),labels=format(seq(1.60,2,by=0.1),nsmall=2),cex.axis=1.5)
axis(1,at=seq(1.65,2,by=0.1),cex.axis=1.2,col.axis="grey")
axis(2,at=seq(40,120,by=10),cex.axis=1.5) 
 
dev.off()

Grafikbeispiel 2

[Bearbeiten]

Quelltext:

parliament<-function(x, labels=names(x), edges=5000, col=rainbow(length(x)), rad.in=0.25, ...) {
  plot(c(-1,1), c(0,1), type="n", axes=FALSE, xlab="", ylab="", ...)
  y=c(0,pi*cumsum(x)/sum(x))
  ang=seq(0,pi,length=edges)
  for (aktiv in 1:(length(y)-1)) {
    poly=ang[ y[aktiv]<=ang & ang<=y[aktiv+1] ]
    polygon(c(cos(poly),0), c(sin(poly),0),col=col[aktiv],border=col[aktiv])
    text( (cos(y[aktiv])+cos(y[aktiv+1])+rad.in*cos(y[aktiv])+rad.in*cos(y[aktiv+1]))/4, (sin(y[aktiv])+sin(y[aktiv+1])+rad.in*sin(y[aktiv])+rad.in*sin(y[aktiv+1]))/4, col="white", labels=paste(labels[aktiv], "\n" ,x[aktiv]), cex=1.2, adj=c(0.5,0.5))
  }
  polygon(rad.in*cos(ang),rad.in*sin(ang),col=par("bg"),border=par("bg"))
} 

x<-c(21,66,7,68,21)
names(x)<-c("FPÖ", "ÖVP", "BZÖ", "SPÖ", "Grüne")

png(filename="Mandate2006.png", width=1300, height=850, pointsize=12)
par(bg="whitesmoke")
parliament(x, col=c("#126ca8", "black", "#ec921a", "red", "#61bb46"), main="Nationalratswahl 2006 - Mandatsverteilung", cex.main=1.7)
dev.off()


Grafikbeispiel 3

[Bearbeiten]

Quelltext:

qs=c(0,0.5,0.75,0.9,0.95,0.99)
cs=heat.colors(length(qs))

qplot<-function(qs,x,pdf,cdf,pfl) {
  plot(x,pdf,type="n",ylim=range(pdf,0)*1.25,xlab="",ylab="")
  for (q in 1:(length(qs)-1)) {
    xd=   x[(cdf>=qs[q])&(cdf<=qs[q+1])]
    yd= pdf[(cdf>=qs[q])&(cdf<=qs[q+1])]
    polygon(c(xd,xd[length(xd)],xd[1]),c(yd,0,0),col=cs[q],border=cs[q])
    lines(c(xd[length(xd)],xd[length(xd)]),c(max(pdf)*1.1-0.01,max(pdf)*1.1+0.01),col=cs[q],lwd=3)
    arrows(xd[length(xd)]-pfl,max(pdf)*1.1,xd[length(xd)],max(pdf)*1.1,lwd=2,length=0.15) 
    text(xd[length(xd)],max(pdf)*1.15,paste("q(",format(qs[q+1]*100),"%)=",format(xd[length(xd)],digits=1,nsmall=1,decimal.mark=","),sep=""),col=cs[q],cex=1.5,adj=c(1,0))
  }
}

png(filename = "Quantile_graph.png", width=1500, height=1000, pointsize=12)
par(mfrow=c(2,1),bg="whitesmoke")

## normalverteilung
x=seq(-0.6,2.3,by=0.0001)
pdf=dnorm(x=x)
cdf=pnorm(q=x) 

qplot(qs,x,pdf,cdf,0.35)
title(main="Quantile der Normalverteilung")

## chi-quadrat verteilung
df=3
x=seq(0,11.3,length=10000)
pdf=dchisq(x=x,df=df)
cdf=pchisq(q=x,df=df)

qplot(qs,x,pdf,cdf,1.3)
title(main="Quantile der chi-Quadrat Verteilung")
dev.off()

Grafikbeispiel 4

[Bearbeiten]

Quelltext:

#value at risk graph

quant=0.10

min=-1.7
max=2.6
mean=2.1
s=seq(min,max,length=10000)
d=dnorm(s,mean=mean)
q=qnorm(quant,mean=mean)
sq=c(s[s<q],q,min)
dq=c(d[s<q],0,0)

png(filename = "VaR_graph.png", width=1300, height=800, pointsize=12)
par(bg="whitesmoke")
plot(s,d,type="n",xlab="Portfoliowert [in Mio. EUR]",ylab="Wahrscheinlichkeit",main="Value at Risk",xlim=range(s)*0.935)
abline(h=0,col="grey")
polygon(x=c(s,max,min),y=c(d,0,0),col="snow3")

polygon(x=sq,y=dq,col="skyblue")


text(x=(q-min)*0.93+min,y=dnorm(q,mean=mean)*0.3,label=paste(format(100*quant),"%",sep=""),col="blue",cex=1.7)

lines(x=c(q,q),y=c(0,dnorm(q,mean=mean)*1.35),col="red",lwd=3)
text(x=(q-min)*0.9+min,y=dnorm(q,mean=mean)*1.4,label=paste("VaR=",format(q, digits=2)," Mio EUR",sep=""),col="red",cex=1.6)

lines(x=c(mean,mean)*0.9,y=c(0,dnorm(mean,mean=mean)*0.95),col="darkgrey",lwd=2)
text(x=mean*0.87,y=dnorm(mean*0.9,mean=mean)*0.66,label=paste("Portfoliowert heute: ",mean*0.9," Mio EUR",sep=""),col="black",srt=90)

dev.off()


Grafikbeispiel 5

[Bearbeiten]

Verwendet werden die Daten aus Beispiel 10.

Der Befehl zum Erzeugen der Grafik lautet:

library(lattice) # Lädt das lattice-Grafikpaket
colors <- c("skyblue4", "blue", "darkgreen","#61bb46")	# Farben für Werte und Labels
key.list <- list(space = "right", 	 # Legende Ausrichtung
       title="Assessed", cex.title=1.2, # Legendenüberschrift und Größe
       points=list(pch=c(0,15,3,8), col=colors, cex=1), # Legendensymbole
       text=list(levels(bsp10$Proxy), cex=1, font=1),	 # Legende mit Schriftgröße und -art
       col=colors)					 # LegendenSchriftfarbe
grafik <- dotplot(Item ~ Score | Case , groups=Proxy, data=bsp10, 
       layout = c(3,4), # Diagramme werden in 3 Spalten und 4 Reihen aufgeteilt
       key = key.list,  # Verwende die Daten aus dem Objekt "key.list"
       xlab = list(label="Score (T-Rasch)", cex=1.5, font=2),  # Label für X-Achse, Schriftgröße, fett
       ylab = list(label="Dimensions", cex=1.5, font=2),       # Label für Y-Achse, Schriftgröße, fett,
       main= list(label="Each kid: first measure self and proxy", cex=2,5),  # Überschrift 
       #sub = list(label="Kinder: alle Erst- und Zweiterhebungen", cex=1, font=3),
       scales = list(cex=1.2, ces=2), # Achsenbeschriftung (Schriftgröße)
       between = list(x=0.5, y=0.5),  # Abstand zwischen den Diagrammen
       cex = 1,		       # Größe der Symbole 
       pch=c(0,15,3,8), col=colors)   # Symbolart der Werte und deren Farbe
update(grafik,
       panel = function(...){panel.grid(h=-1,v=-20) # Gitter hinzufügen
       panel.dotplot(...)  })
rm(colors,key.list,grafik)

siehe auch

[Bearbeiten]


Inhaltsverzeichnis

[Bearbeiten]