GNU R Druckversion
Wikibooksorg
3 Dezember 2012
On the 28th of April 2012 the contents of the English as well as German Wikibooks and Wikipedia projects werelicensed under Creative Commons Attribution-ShareAlike 30 Unported license An URI to this license is givenin the list of figures on page 251 If this document is a derived work from the contents of one of these projectsand the content was still licensed by the project under this license at the time of derivation this document hasto be licensed under the same a similar or a compatible license as stated in section 4b of the license Thelist of contributors is included in chapter Contributors on page 249 The licenses GPL LGPL and GFDL areincluded in chapter Licenses on page 255 since this book andor parts of it may or may not be licensed underone or more of these licenses and thus require inclusion of these licenses The licenses of the figures are givenin the list of figures on page 251 This PDF was generated by the LATEX typesetting software The LATEX sourcecode is included as an attachment (source7ztxt) in this PDF file To extract the source from the PDFfile we recommend the use of httpwwwpdflabscomtoolspdftk-the-pdf-toolkitutility or clicking the paper clip attachment symbol on the lower left of your PDF Viewer selecting SaveAttachment After extracting it from the PDF file you have to rename it to source7z To uncompressthe resulting archive we recommend the use of httpwww7-ziporg The LATEX source itselfwas generated by a program written by Dirk HAtildeijnniger which is freely available under an open sourcelicense from httpdewikibooksorgwikiBenutzerDirk_Huennigerwb2pdf Thisdistribution also contains a configured version of the pdflatex compiler with all necessary packages andfonts needed to compile the LATEX source included in this PDF file
Inhaltsverzeichnis
I Einleitung 31 Vorwort 5
11 Vorwort 52 Was ist R 7
21 Was ist R 722 Warum R 723 Was spricht gegen R 824 Literatur 8
3 Installation 931 Unix Linux 932 Windows 933 MacOS 1034 Weblinks 1035 Quellen 10
4 R starten 1141 R beenden 11
5 Hilfe 1351 apropos() 1352 help() 1353 helpstart() 1454 RSiteSearch() 14
6 Die Basispakete 1561 R Standardpakete 15
7 Zusatzpakete 1771 Installation per installpackages 1772 Fehlermeldung bei Mac OS X 1773 Installation von Zusatzpaketen uumlber die Shell 1874 Zusatzpakete aktivieren und deaktivieren 1875 Zusatzpakete aktualisieren 1876 Uumlbersicht uumlber installierte Zusatzpakete 1977 siehe auch 19
II R benutzen 218 Rechnen mit R 23
81 Beispiele 2382 Wurzel 2483 Kommastellen 2484 Runden 2585 Integrieren 26
9 Daten in R 2791 Variablen 27
III
Inhaltsverzeichnis
92 Einfache Datentypen (modes) 2893 Komplexe Datentypen Klassen 2994 Zeichenketten 3095 Vektoren 30
10 Manuelle Dateneingabe 33101 Eingabe von logischen Werten 33
11 Umgang mit Datensaumltzen (Erstellen Auswaumlhlen und Filtern) 3512 Datenimport und -export 37
121 Import 37122 Export 43
13 Daten laden und speichern 4514 Daten laden 4715 Daten speichern 49
151 Arbeitsspeicher speichern 49152 einzelne Objekte speichern 49
16 Arbeitsverzeichnis 5117 Daten selektieren 5318 Daten auswaumlhlen 5519 Matrix- und Listenoperationen 57
191 Matrix- und Listenoperationen 5720 Benutzeroberflaumlchen und Erweiterungen 5921 Graphische Benutzeroberflaumlchen 61
211 JGR (Jaguar) 61212 R Commander 61213 RKWard 61214 Sciviews-R 62215 RStudio 62
22 Sonstige Schnittstellen 63221 R in Emacs ESS 63
23 Automation und dynamische Dokumenterstellung 6524 Batchmode 6725 Dynamische Dokumenterstellung mit dem Paket (S-odf-)Weave 69
251 Grundprinzipien dynamischer Dokumenterstellung 69252 R und Open Office 70253 R und Latex 71254 Dynamische Webseiten mit R 71255 Ausblick 71256 Weblinks 72
III Statistik mit R 7326 Diagramme und Grafiken erzeugen 75
261 Funktionen zum Erstellen von Diagrammen 75262 Funktionen zum Erstellen zusaumltzlicher grafischer Elemente 76263 Grafiken speichern 76264 siehe auch 76265 Literatur 76266 Weblinks 76
27 Deskriptive Statistik 79271 Gruppenspezifische Auswertung von Variablen 82
IV
Inhaltsverzeichnis
28 Regressionsanalyse 85281 Einleitung 85282 Lineare Regression 85
29 Clusteranalyse 8930 Signifikanztests 91
301 Testauswahl 91302 Testdurchfuumlhrung in R 93303 Weblinks 93
31 Rasch-Modelle 9532 Package eRm 97
321 Installation 97322 Das dichotome logistische Rasch-Modell 97323 Das linear-logistische Test-Modell 113324 Das Ratingskalen-Modell 113325 Das partial-credit Modell 120326 Das lineare Ratingskalen-Modell 120327 Das lineare partial-credit Modell 121328 unterstuumltze Funktionen im eRm-Package 121
33 Package ltm 12534 Literatur 12735 Weblinks 12936 Datum- und Zeitfunktionen 13137 Einleitung 13338 Grundlegende Datumfunktionen 13539 Analyse von Zeitreihen 13940 Block-Randomisierung 141
401 Einleitung 141402 blockrand 141403 siehe auch 142
IV Programmieren mit R 14341 Programmieren mit R 145
411 Programmieren mit R 145412 siehe auch 148
42 Eigene Funktionen programmieren 149421 R-Sprache 149422 siehe auch 151423 Literatur 151424 Weblinks 151
43 Dateioperationen 153431 Dateioperationen 153
44 Eigene Zusatzpakete erstellen 155441 Paket erstellen 155442 Dokumentation schreiben 156443 Paket uumlberpruumlfen und fertig stellen 158444 Paket zum CRAN hochladen 159445 Weblinks 159
45 Andere Programmiersprachen einbinden 161451 C++ 161
V
Inhaltsverzeichnis
452 Java 16146 Finden von Programmfehlern und Debugging 163
461 Manuelles Einfuumlgen von Ausgabewerten 163462 Gaumlngige Fehler 163463 Error-Recovery mit dem Browser 164464 Verfolgen von Funktionen mit trace 166
V Anhang 16747 Anwendungsbeispiele 16948 Datenbeispiele 171
481 Beispiel 1 171482 Beispiel 2 171483 Beispiel 3 172484 Beispiel 4 172485 Beispiel 5 173486 Beispiel 6 173487 Beispiel 7 178488 Beispiel 8 179489 Beispiel 9 1814810 Beispiel 10 184
49 Graphikbeispiele 187491 Graphikbeispiel 1 187492 Graphikbeispiel 2 189493 Graphikbeispiel 3 190494 Graphikbeispiel 4 191495 Graphikbeispiel 5 193
50 siehe auch 19551 Befehle-Index 197
511 A 197512 B 198513 C 199514 D 201515 E 202516 F 203517 G 204518 H 205519 I 2065110 J 2085111 K 2095112 L 2105113 M 2115114 N 2135115 O 2145116 P 2155117 Q 2175118 R 2185119 S 2195120 T 2225121 U 223
VI
Inhaltsverzeichnis
5122 V 2245123 W 2255124 X 2265125 Y 2275126 Z 228
52 Loumlsung der Uumlbungsaufgaben 22953 Umgang mit Datensaumltzen (Erstellen Auswaumlhlen und Filtern) 23154 Programmierbeispiele 233
541 Beispiel 1 Abschlussnote 233542 Beispiel 2 Cut-Off-Points 233543 Beispiel 3 Entfernen von Umlauten 235544 Beispiel 4 Zeit Sampler 236545 siehe auch 236
55 Beispielskripte 237551 Importieren von SPSS-Datensaumltzen 237
56 Uumlbersicht programmspezifischer Voreinstellungen 23957 Das wikibooks-Zusatzpaket 243
571 Installation 243572 Paket aktivieren 243573 Paketinhalt 244574 Weblinks 246575 siehe auch 247
58 Autoren 249Abbildungsverzeichnis 25159 Licenses 255
591 GNU GENERAL PUBLIC LICENSE 255592 GNU Free Documentation License 256593 GNU Lesser General Public License 256
1
Teil I
Einleitung
3
1 Vorwort
11 Vorwort
Statistiksoftware gehoumlrt heute wie Datenbanksysteme oder Office-Programme zu den entscheidendenSoftwarekomponenten in Unternehmen wie auch in der Forschung Dabei kann die Statistiksoftwareversteckt als eine Komponente zB im Data Mining vorkommen oder als eigenstaumlndige Software wieR genutzt werden Spaumlter werden wir noch sehen dass man R auch in andere Software integrierenkann Statistiksoftware wie R wird heute nicht primaumlr im Kerngebiet der Mathematik angewandtVielmehr wird R fuumlr die Verarbeitung wissenschaftlicher und oumlkonomischer Daten verwandt So istR heute eine gefragte Software bei der Auswertung genetischer Experimente Ohne die moderneComputertechnik und entsprechender Software waumlre die moderne Genetik kaum denkbar
Dieses Buch soll den Leser in einer einfachen Art und Weise und anhand kleiner Beispiele in diePraxis der Software R einfuumlhren Nach dem Lesen und Durcharbeiten des Buchs wird der Leser in derLage sein R sicher zu benutzen Weiterhin werden alle Aspekte von R in diesem Buch angesprochenund erlaumlutert Dadurch soll es dem erfahren R-Benutzer als stetiges Nachschlagewerk dienen Fuumlr dasVerstaumlndnis dieses Buches werden keine Programmierkenntnisse vorausgesetzt Weil die statistischeAuswertung von Daten die Kernaufgabe von R ist ist es fuumlr den Leser hilfreich wenn er Erfahrungenauf dem Gebiet der Statistik bzw deren Anwendung hat
TipEine Einfuumlhrung in Statistik bietet das Wikibook Mathematik_Statistik1
Zur Zeit ist dieses Buch nicht vollstaumlndig und auch nicht konsistent Wenn beim Lesen der Text beimLeser Fragen aufgeworfen werden wenn Passagen nicht ausreichend verstaumlndlich sind oder wennDinge fehlen bitte nutzen Sie die Diskussionsfunktion um uns die Autoren dieses Buches daraufhinzuweisen Anregungen sind gerne willkommen
1 httpdewikibooksorgwikiMathematik3A_Statistik
5
2 Was ist R
21 Was ist R
Dieses Buch fuumlhrt in das Programm R ein R steht dabei fuumlr The R Project for Statistical Computing
bull R ist eine Software zur statistischen Datenverarbeitung sowie deren grafischer Darstellungen(Visualisierung)
bull R ist eine Umsetzung der statistischen Programmiersprache Sbull R laumluft unter diversen UNIX- Linux- und Unix-aumlhnlichen Betriebsystemen sowie auf Windows
und Mac OS X Aumlltere R-Versionen sind auch noch fuumlr das klassische Mac OS verfuumlgbar Fuumlr vieleBetriebssysteme gibt es bereits kompilierte Pakete
bull Die Sprache kann leicht durch neue Funktionen erweitert werdenbull Eine groszlige Anzahl von existierenden Zusatzpaketen ergaumlnzen die R-Funktionalitaumlt um Methoden
aus Spezial- und Anwendungsbereichen der Statistikbull R kann mit anderen Programmiersprachen wie GRASS Perl Python C oder Java verbunden
werdenbull R kann sowohl interaktiv also im Einzelbefehlsmodus als auch als Skriptsprache und im Batch-
Modus verwendet werdenbull Der R-Quelltext wird unter der GNU General Public License (GPL) der Free Software Foundation
veroumlffentlicht
Die Homepage von R lautet httpwwwr-projectorg
http
Zusaumltzliche Skripte zur Einfuumlhrung in R koumlnnen im Internet kostenfrei abgerufen werden (zB Handl20061) Des Weiteren stehen diverse (meist englischsprachige) Internetseiten (zB Das R Wiki2)sowie Publikationen (siehe Literatur) zum Thema R zur Verfuumlgung
22 Warum R
bull Neben gaumlngigen Programmen zur statistischen Auswertung wie beispielsweise bdquoSPSSldquo oderbdquoSTATAldquo bietet R den Vorteil dass es auf der ganzen Welt kostenlos (unter der freien GNU-Lizenz) zur Verfuumlgung steht
bull R kann die meisten gaumlngigen Formate importieren gewaumlhrleistet volle Kontrolle uumlber die Datenund bietet ein verlaumlssliches quelloffenes Format fuumlr erstellte Datensaumltze
bull Daruumlber hinaus stellt R zT maumlchtigere und mehr Auswertungsverfahren zur Verfuumlgung als andereProgramme
1 httpwww2wiwiuni-bielefeldde~frohnMitarbeiterHandlstagrundhtml2 httprwikisciviewsorgdokuphp
7
Was ist R
bull R ist eine Programmierumgebung Funktionen koumlnnen bequem den eigenen Beduumlrfnissen angepasstwerden Komplexe Probleme lassen sich auch dann loumlsen wenn die Entwickler diese (noch) nichtimplementiert haben
bull R wird von der Scientific Community kontinuierlich weiterentwickelt und erweitert Neue sta-tistische Verfahren werden in der Regel auch in R integriert Ein standardisiertes Pakete-Systemerleichtert die Nachinstallation ebenso wie die Veroumlffentlichung eigener Pakete
bull R erstellt professionelle Graphiken in einer Vielzahl an Formatenbull R ist auch eine funktionierende Benutzer- und Entwickler-Gemeinschaft die fuumlr Fragen offen ist
und so den Einstieg erleichtertbull R kann systemuumlbergreifend auf verschiedenen Plattformen genutzt werdenbull R verfuumlgt uumlber aumlusserst flexible Schnittstellen der Daten-Ein- und -Ausgabe und kann mit verschie-
denen anderen Applikationen zusammenarbeitenbull R kann in einem Batch-Mode zur automatisierten Auswertung und Dokumenterstellung verwendet
werden und laumlsst sich auch in Webserver dynamische Websites integrierenbull R ist trotz graphischer Benutzeroberflaumlchen textbasiert Im Zentrum steht nicht Design sondern
Funktion
23 Was spricht gegen R
bull Fuumlr den Anfaumlnger ist die Funktionsweise und Bedienung von R zweifellos gewoumlhnungsbeduumlrftigbull Bei der Programmierung in R faumlllt im Vergleich mit modernen Sprachen auf dass Einiges in
unerwarteter Weise funktioniertbull Bestimmte Grundverfahren (z B Haumlufigkeitsgewichte) sind zur Zeit nur umstaumlndlich oder gar
nicht implementiert
24 Literatur
Mit folgender Literatur haben wir einen guten Einstieg in R gefunden
bull Guumlnter Faes (2007) Einfuumlhrung in R Ein Kochbuch zur statistischen Datenanalyse mit R BoDISBN 9783833491849
bull Dubravko Dolic (2003) bdquoStatistik mit R Einfuumlhrung fuumlr Wirtschafts- und SozialwissenschaftlerldquoOldenbourg ISBN 3486275372
8
3 Installation
Da R zur freien Verfuumlgung steht kann eine Installationsdatei aus dem Internet herunter geladenwerden Alle Downloads zu R stehen unter dem bdquoComprehensive R Archive Networkldquo (CRAN) zurVerfuumlgung
Rufen Sie zur Installation die Webseite httpcranr-projectorgmirrorshtmlauf und waumlhlen Sie einen Server von dem aus Sie R herunterladen moumlchten Eine gute Down-loadverbindung bieten normalerweise solche Server deren Standort nicht all zu weit von IhremWohnsitz entfernt ist Nachdem Sie ein Installationspaket fuumlr Ihr System (Windows Apple Linux)heruntergeladen haben installieren Sie R Dies erfolgt in der Regel durch einen Doppelklick auf dieInstallationsdatei
31 Unix Linux
bull Vorkompiliertes RPM - Paket fuumlr die entsprechende Distribution herunterladenbull Paket installierenbull in der Shell mit R starten
Fuumlr Debian ist auch eine Installation mit apt-get moumlglich Optional kann die neueste R-Version uumlbereinen Backport installiert werden1
Fuumlr Ubuntu heiszligt das entsprechende Paket r-recommended
Fuumlr Ubuntu bietet das R-Project Repositories an Diese sind an die jeweiligen Releases angepaszligt undbieten bisweilen aktuellere Versionen als Ubuntu2
Fuumlr Solaris (OpenSolaris) wird ein Packet auf sunfreewarecom angeboten
32 Windows
1 Das Setup-Programm im Paket base herunterladen (ca 23 MB)2 Dieses Programm ausfuumlhren3 Die R-Oberflaumlche unter Windows startet ein Textfenster das der R-Shell unter Unix entspricht
1 httpcranr-projectorgbinlinuxdebian Debian GNU R Repository2 httpcranr-projectorgbinlinuxubuntu
9
Installation
33 MacOS
bull Installer herunterladen und ausfuumlhren
34 Weblinks
bull Anleitung zur Einbindung der Ubunturepositories des R-Projektes3
35 Quellen
enR ProgrammingSettings4 ptR (linguagem de programaccedilatildeo)Instalaccedilatildeo5
3 httpcranr-projectorgbinlinuxubuntu4 httpenwikibooksorgwikiR20Programming2FSettings
5 httpptwikibooksorgwikiR2028linguagem20de20programaE7E3o292FInstalaE7E3o
10
4 R starten
Nachdem Sie R installiert haben starten Sie R mit einem Doppelklick auf das R-Symbol in IhremProgramm-Verzeichnis
Unter Linux wird R mit dem Befehl R in der Kommandozeile gestartet
R
Nachdem Sie R gestartet haben erscheint ein Begruumlszligungstext
R Copyright 2006 The R Foundation for Statistical ComputingVersion 231 (2006-06-01)ISBN 3-900051-07-0
R ist freie Software und kommt OHNE JEGLICHE GARANTIESie sind eingeladen es unter bestimmten Bedingungen weiter zuverbreiten
Tippen Sie license() or licence() fuumlr Details dazu
R ist ein Gemeinschaftsprojekt mit vielen BeitragendenTippen Sie contributors() fuumlr mehr Information und citation()um zu erfahren wie R oder R packages in Publikationen zitiert werdenkoumlnnen
Tippen Sie demo() fuumlr einige Demos help() fuumlr on-line Hilfeoder helpstart() fuumlr eine HTML Browserschnittstelle zur Hilfe
Tippen Sie q() um R zu verlassengt
Das Symbol gt zeigt an dass der R-Prozessor bereit ist und Sie nun Ihre Befehle eingebenkoumlnnen Beispielsweise koumlnnen Sie direkt den Anmerkungen des Begruumlszligungstexts folgen und dieLizenzbedingungen von R aufrufen mit
gt licence()
41 R beenden
Zum Beenden gibt man q()1 ein Es erscheint die Frage
Save workspace image [ync]
1 httpdewikibooksorgwikiGNU_R3A_q
11
R starten
Die Eingabe von y (yes) speichert die aktuelle Sitzungkonfiguration (zB Objekte Liste der ge-ladenen Bibliotheken) n (no) verwirft die aktuellen Sitzungsaumlnderungen c (cancel) bricht denBeendungsvorgang ab
12
5 Hilfe
Zu jeder R-Funktionsweise gibt es eine R-interne Hilfeseite Diese kann aufgerufen werden wennSie vor die gefragte Funktion ein schreiben zB
gt 1licence
Es oumlffnet sich nun ein Hilfefenster in welchem die gefragte Funktion erlaumlutert wird (leider nur aufenglisch) In der ersten Zeile der Hilfedatei wird der Name der Funktion angezeigt gefolgt von demPaket in welchem diese vorhanden ist Des Weiteren werden alle Optionen angezeigt die mit derFunktion angegeben werden koumlnnen
51 apropos()
apropos()2 sucht einen Ausdruck in der Liste der Funktionen und Vektorvariablen
3apropos4(plot) ltcodegt
liefert eine Liste der Funktionsnamen und Vektoren welche den Ausdruck plot enthalten
52 help()
Die Funktion help() zeigt die selben R-interne Dokumentation zu einem Befehl an wie das obenbeschriebene Fragezeichen () Beispielsweise liefert
help5(plot)
die Dokumentation zum Befehl plot()6 Der Aufruf laumlsst sich aber wie oben beschrieben abkuumlrzenals78plot
2 httpdewikibooksorgwikiGNU20R3A20apropos5 httpdewikibooksorgwikiGNU20R3A20help6 httpdewikibooksorgwikiGNU20R3A20plot7 httpdewikibooksorgwikiGNU20R3A203F8 httpdewikibooksorgwiki3F
13
Hilfe
53 helpstart()
Mit helpstart()9 werden im Standardbrowser die Links zu den englischsprachigen R-Anleitungen angezeigt Sie sind im Installationsverzeichnis von R unter dochtml abgelegt Enthaltensind unter anderem eine Einfuumlhrung in R Datenim- und export R-Installation und AdministrationReferenzen zu den Paketen sowie eine Suchmaschine mit einem Verzeichnis von Schlagworten
54 RSiteSearch()
Die Funktion RSiteSearch(Suchbegriff)10 ist ein einfacher Weg uumlber das Internet meh-rere Hilfeseiten auf einmal zu durchsuchen Im Internetbrowser werden die Treffer aus der Suche inR-Dokumenten den Hilfeseiten der Funktionen und der R-help-Mailingliste aufgelistet
9 httpdewikibooksorgwikiGNU20R3A20helpstart10 httpdewikibooksorgwikiGNU20R3A20RSiteSearch2829
14
6 Die Basispakete
61 R Standardpakete
bull base1 -- Grundliegende Funktionenbull graphics2 -- Die wichtigsten Funktionen zum Erstellen von Grafikenbull stats3 -- Wichtige Statistikfunktionenbull utils4 -- Pakete installieren Hilfefunktionen Dateneingabe
1 httpdewikibooksorgwikiGNU_R3A20base2 httpdewikibooksorgwikiGNU_R3A20graphics3 httpdewikibooksorgwikiGNU_R3A20stats4 httpdewikibooksorgwikiGNU_R3A20utils
15
7 Zusatzpakete
Da R ein offenes Projekt ist an dem jeder mitarbeiten kann stehen zahlreiche Zusatzpakete mitzusaumltzlichen Funktionen zur Verfuumlgung
Sofern Sie uumlber einen Internetanschluss verfuumlgen koumlnnen Sie diese Pakete direkt von der R-Kommandozeile nachinstallieren
71 Installation per installpackages
Der Befehl hierzu lautet installpackages()1
Eine Liste aller zur Verfuumlgung stehenden Zusatzpakete finden Sie unter httpcranr-projectorgwebpackagesavailable_packages_by_namehtml
Wenn Sie beispielsweise das bdquoforeignldquo-Paket installieren moumlchten geben Sie folgenden Befehl ein
gt installpackages(ldquoforeignldquo)
Manche der Zusatzpakete benoumltigen weitere (abhaumlngige) Zusatzpakete Diese werden automatischmitinstalliert wenn Sie den Befehl mit einer Option erweitert eingeben
gt installpackages(ldquoforeignldquo dependencies=TRUE)
Sobald Sie den Befehl eingegeben haben werden Sie aufgefordert einen Server auszuwaumlhlenvon dem aus Sie die Zusatzpakete installieren moumlchten Waumlhlen Sie einen Server aus Ihrer Naumlheund bestaumltigen Sie mit bdquoOKldquo Sie koumlnnen den Server mit dem Befehl chooseCRANmirror()2
wechseln Dies ist zB notwendig wenn das gewuumlnschte Zusatzpaket auf dem ausgewaumlhlten Servernicht verfuumlgbar ist
Weitere Pakete sind zu finden unter httpcranr-projectorg
72 Fehlermeldung bei Mac OS X
Wenn Sie R von einem Mac aus betreiben und ein Zusatzpaket installieren moumlchten bekommen Sieunter Umstaumlnden folgende Fehlermeldung
1 httpdewikibooksorgwikiGNU20R3A20installpackages2 httpdewikibooksorgwikiGNU20R3A20chooseCRANmirror
17
Zusatzpakete
cannot create HTML package index in makepackageshtml()
Dies ist keine echte Fehlermeldung Das Problem liegt darin dass die Hilfedateien und -verzeichnisseerst nach dem ersten Aufruf von bdquoHilfeldquo auf Ihrem Rechner angelegt werden Waumlhlen Sie also ausdem Menuuml bdquoHilfe =gt R-Hilfeldquo aus Es erscheint die R-Hilfe-Seite Von nun an ist das erforderlicheVerzeichnis angelegt und die Fehlermeldung sollte nicht mehr erscheinen
73 Installation von Zusatzpaketen uumlber die Shell
Falls Sie ein Paket manuell uumlber die CRAN-Webseiten heruntergeladen haben muss dieses uumlber dieKommandozeile installiert werden Wechseln Sie hierzu auf der Shell in das Verzeichnis in welchesSie die tar-Datei heruntergeladen haben und geben ein
R CMD INSTALL paket
wobei Sie paket durch den Datei- bzwPaketnamen (ohne targz) ersetzen
74 Zusatzpakete aktivieren und deaktivieren
Bitte beachten Sie dass die Funktionen der Zusatzpakete zunaumlchst nicht aufgerufen werden koumlnnenHierfuumlr muumlssen Sie das entsprechende Paket zuerst mit library(PAKETNAME) aktivieren Umbeispielsweise das bdquoforeignldquo-Paket zu aktivieren geben Sie also ein
gt library3(foreign)
Wenn die Funktionen der Zusatzpakete nicht mehr benoumltigt werden koumlnnen diese mitdetach(ldquopackagePAKETNAMEldquo) deaktiviert werden in unserem Fall also per
gt detach4(packageforeign)
75 Zusatzpakete aktualisieren
Die R-Basis- und Zusatzpakete lassen sich mit updatepackages()5 aktualisieren
5 httpdewikibooksorgwikiGNU20R3A20updatepackages
18
Uumlbersicht uumlber installierte Zusatzpakete
76 Uumlbersicht uumlber installierte Zusatzpakete
Mit installedpackages()6 erhalten Sie ein Uumlbersicht uumlber alle installierten Zusatzpaketesowie deren Versionen
77 siehe auch
bull Das wikibooks-Zusatzpaket7
bull Eigene Zusatzpakete erstellen8
6 httpdewikibooksorgwikiGNU20R3A20installedpackages7 Kapitel 57 auf Seite 2438 Kapitel 44 auf Seite 155
19
Teil II
R benutzen
21
8 Rechnen mit R
R ist unter anderem ein maumlchtiger Taschenrechner Folgende Rechenfunktionen koumlnnen mit Rausgefuumlhrt werden
Additi-on
+
Sub-trakti-on
-
Multi-plikati-on
Divisi-on
Expo-nenten
ˆ oder
Modu-lo
Wur-zel
sqrt1(x)
81 Beispiele
gt 2+4[1] 6
gt 4-1[1] 3
gt 22[1] 4
gt 42[1] 2
gt 2ˆ3[1] 8
1 httpdewikibooksorgwikiGNU20R3A20sqrt
23
Rechnen mit R
gt 012[1] 001
gt 103[1] 1
gt (-1)4[1] 3
gt sqrt2(100)[1] 10
82 Wurzel
Das Ziehen einer Wurzel erfolgt uumlber die Funktion sqrt3 Damit Funktionen arbeiten koumlnnenbenoumltigen sie ein bdquoArgumentldquo Das Argument ist in unserem Fall die Zahl 100 da wir die Wurzel aus100 ziehen wollen Argumente werden der Funktion in runden Klammern angehaumlngt So erklaumlrt sichder Befehl sqrt(100) (siehe oben)
83 Kommastellen
In R ist das Dezimaltrennzeichen ein Punkt (und nicht wie im deutschsprachigen Raum uumlblich einKomma)
gt 201 + 42[1] 621
gt 26 372[1] 9672
831 Nachkommastellen
R zeigt standardmaumlszligig 6 Nachkommastellen an Intern rechnet R mit doppelter Genauig-keit4 Damit sind Nummern mit ca 17 Stellen (1 Ziffer + 16 Nachkommastellen oder ebeneine 17 stellige Zahl ohne Nachkommastellen) repraumlsentierbar Moumlchte man die Nachkomma-stellen entsprechend angezeigt bekommen so kann man dies mit der options5-Funktion einstellen
options(digits=17)
Nach dieser Eingabe liefert R Ergebnisse mit bis zu 16 Nachkommastellen
3 httpdewikibooksorgwikiGNU20R3A20sqrt4 httpdewikipediaorgwikiDouble_precision5 Kapitel 56 auf Seite 239
24
Runden
84 Runden
R zeigt standardmaumlszligig 6 Nachkommastellen an Ziehen wir die Wurzel aus 3 erhalten wir folgendesErgebnis
gt sqrt6(3)[1] 1732051
Dieses Ergebnis kann mit der Funktion round gerundet werden
gt round7(sqrt8(3))[1] 2
Es besteht des Weiteren die Moumlglichkeit die Anzahl der Nachkommastellen in der round-Funktionmitanzugeben Die round-Funktion kann zwei Argumente verarbeiten Das erste Argument heiszligtx und ist die Zahl die gerundet werden soll (in unserem Beispiel bdquoWurzel aus 3ldquo) Das zweiteArgument heiszligt bdquodigitsldquo und gibt an auf wieviele Nachkommastellen das Argument x gerundetwerden soll Wollen wir das Ergebnis mit zwei Nachkommastellen angegeben bekommen so lautetder Befehl
gt round9(x=sqrt(3) digits=2)[1] 173
Wenn man den Namen des Argumentes mit in die Funktion schreibt spielt die Reihenfolge derArgumente keine Rolle So koumlnnten wir die Berechnung in unserem Falle auch erzeugen durch
gt round10(digits=2 x=sqrt(3))[1] 173
Eine Uumlbersicht uumlber die Argumente einer Funktion (und ihrer Reihenfolge) liefert die Help-Seite diewir in unserem Falle aufrufen koumlnnen per
gt 11round
Wenn man die Reihenfolge der Argumente einer Funktion kennt so muss man die Argumente nichtunbedingt als solche benennen In unserem Beispiel funktioniert auch die Eingabe
gt round12(sqrt13(3) 2)[1] 173
Dies liegt daran dass das erste Argument x (in unserem Falle sqrt(3)) und das zweite Argumentdigits (in unserem Falle 2 Nachkommastellen) heiszligt Wichtig ist hierbei allerdings dass man dieArgumentwerte in der tatsaumlchlich geforderten Reihenfolge schreibt welche durch die Help-Seite(round) eingesehen werden kann
25
Rechnen mit R
85 Integrieren
Zum Integrieren kann die Funktion integrate14 verwendet werden In folgendem Beispielwird die Dichtefunktion der Standardnormalverteilung von 0 bis +Unendlich integriert (und damitdie Wahrscheinlichkeit bestimmt dass eine Standardnormalverteilung einen positiven Wert annimmt)
gt integrate(dnorm 0 Inf)05 with absolute error lt 47e-05
Moumlchte man der zu integrierenden Funktion weitere Parameter uumlbergeben kann man das imAnschluss an die drei ersten Parameter der Funktion integrate() tun In folgendem Beispiel integrierenwir die Dichte einer N(25ˆ2) verteilten Zufallsgroumlszlige von 0 bis +Unendlich
gt integrate(dnorm 0 Inf mean=1 sd=5)05792597 with absolute error lt 14e-05
14 httpdewikibooksorgwikiGNU20R3A20integrate
26
9 Daten in R
Daten in R koumlnnen in Form verschiedener Objekte auftreten und auf vielfaumlltige Weise manipuliertwerden Sie koumlnnen direkt eingegeben oder uumlber eine Textdatei oder Datenbank eingelesen undausgegeben werden1
91 Variablen
Variablen dienen in R wie in anderen Programmiersprachen der Speicherung von Daten Dies koumlnnensowohl einfache Datentypen sein oder auch komplexe Datentypen wie Vektoren Variablen bestehenaus einem Namen und einem Wert Der Name darf nicht mit einer Zahl beginnen Variablennamenwie 1r sind in R nicht erlaubt Der Wert einer Variable kann in R auf zwei Weisen zugewiesenwerden
gt x=10gt ylt-20gt x[1] 10gt y[1] 20gt
Der ersten Variable mit dem Namen x wurde der Wert 10 zugewiesen mittels = Zeichen der Wertvon y wurde mittels lt- zugewiesen Beide Weisen bedeuten das gleiche Anschlieszligend wurden dieWerte ausgegeben Dazu muss man einfach den Variablennamen eintippen Im Gegensatz zu vielenanderen Programmiersprachen wird der Typ einer Variable nicht explizit definiert
R unterscheidet zwischen Groszlig- und Kleinschreibung bei den Variablennamen
gt XFehler Objekt X nicht gefundengt x[1] 10
Die Variable X wurde nicht gefunden die Variable x schon
911 Den Wert von Variablen ausgeben
Durch die einfache Eingabe eines Variablennamens in die R-Konsole wird der Inhalt der Variableausgegeben Dies gilt auch fuumlr Vektoren oder Matrizen
1 Kapitel 12 auf Seite 37
27
Daten in R
z[1] 50 30 40 80 60 25 00 13
912 Variablen anzeigen und Variablen loumlschen
Der Befehl ls()2 listet alle Variablen auf die sich in der aktuellen Worksession befinden Genausoeinfach kann man auch Variablen loumlschen Dies geschieht durch den Befehl rm()3 und die Angabedes Variablennamen in der Klammer
gt ls()[1] bigtable bt fl names t100 ttgt rm(t100)gt ls()[1] bigtable bt fl names ttgt
In diesem Beispiel wurden zuerst alle Variablennamen aufgelistet und anschlieszligend wurde dieVariable t100 mittels rm geloumlscht
913 Variablen vergleichen
Das Vergleichen von zwei Variablen ist vor allem in der Programmierung sehr wichtig
gt x==y[1] FALSEgt y=10gt x==y[1] TRUE
Beim Vergleich der beiden Variabel x und y werden deren Inhalte verglichen Mittels == wirdverglichen ob der Wert beider Variablen gleich ist Dieser Fakt klingt trivial aber in einigen Objekt-orientierten Programmiersprachen wird dies anders gehandhabt
92 Einfache Datentypen (modes)
Bei der Einfuumlhrung der Variablen wurde nur kurz erwaumlhnt dass Variablen verschiedene Dinge be-inhalten koumlnnen Welche Datentypen dies sein koumlnnen wird in diesem und den folgenden Abschnittenerlaumlutert Prinzipiell gibt es in R drei Datentypen einfache Datentypen komplexe Datentypen undspeziellere Datentypen Wir beginnen mit den einfachen Datentypen die in den bisherigen Beispielenauch schon eingesetzt haben Die wesentlichen einfachen Datentypen sind
bull numeric fuumlr Zahlen (wobei zwischen integer und double unterschieden werden kann)bull complex fuumlr komplexe Zahlenbull logical fuumlr logische Werte
2 httpdewikibooksorgwikiGNU20R3A20ls3 httpdewikibooksorgwikiGNU20R3A20rm
28
Komplexe Datentypen Klassen
bull character fuumlr Zeichenbull raw fuumlr Bytes
gt 5gt 3i+2gt TRUEgt abcdegt asraw(65)
Zusaumltzlich gibt es einige etwas speziellere Datentypen die zunaumlchst nicht weiter behandelt werdensollen
bull function fuumlr Funktionenbull call fuumlr Funktionsaufrufebull expression fuumlr Ausdruumlcke
Mit der Funktion mode() laumlsst sich der Datentyp eines Objekts bestimmen Der mode ist eine grund-legende Eigenschaft eines jeden Objekts Eine weitere grundlegende Eigenschaft ist length()Zusaumltzliche Eigenschaften koumlnnen mit attributes() ermittelt werden
93 Komplexe Datentypen Klassen
Aus einfachen Daten lassen sich verschiedene Arten von Datenstrukturen zusammensetzen Diessind
bull vector fuumlr Listen von Objekten gleichen Typsbull list fuumlr beliebige Listen von Objekten (auch rekursiv)bull factor fuumlr Vektoren zur Gruppierung von Objektenbull matrixbull arraybull dataframebull
Welche Datenstruktur ein Objekt besitzt kann mit class() ermittelt werden Klassen sind einallgemeines Konzept von erweiterten Datentypen Jedes Objekt besitzt eine Klasse die mit einemeinfachen Datentyp uumlbereinstimmt oder zusaumltzlich festgelegt werden kann
Klassen sind wichtig fuumlr so genannte generische Funktionen die je abhaumlngig von der Klasse einesuumlbergebenen Objekts arbeiten Beispielsweise gibt es die Klasse Date mit der ein numerischer Wertals Datum interpretiert werden kann Die Klasse eines Objekts laumlsst sich mit class() feststellen
d lt- asDate4(2005-01-01) Umwandlung einer Zeichenkette in einDate-Objektmode5(d)[1] numericclass6(d)[1] Date
29
Daten in R
94 Zeichenketten
Zeichen oder Zeichenketten werden mit einfachen oder doppelten Anfuumlhrungszeichen geschriebenDabei werden die Daten als n-dimensionale Vektoren gespeichert Mehrere dieser Vektoren koumlnnenzu einer Matrix zusammengefuumlgt werden Die Vektoren koumlnnen drei verschiedene Datentypenenthalten numerische und logische Werte sowie Text Des weiteren existieren Funktionen mitwelchen Datenreihen erzeugt werden koumlnnen
h lt- Hallow lt- Weltpaste(hwsep= )[1] Hallo Welt
In diesem Beispiel werden zwei Zeichenketten miteinander verknuumlpft und ein Separator zwischenden Zeichenketten eingefuumlgt Es werden also eigentlich drei Zeichenketten miteinander verknuumlpftFuumlr diese Zeichenkettenverknuumlpfung wird der Befehl paste7 benutzt
Die Laumlnge von Zeichenketten laumlsst sich mit dem Befehl nchar8 ermitteln
gt x= ABCgt nchar(x)[1] 4
Die Zeichenkette x hat die Laumlnge 4 das Leerzeichen vor dem ersten A wird mitgezaumlhlt
Zeichenketten lassen sich mit Hilfe verschiedener Befehle wie split grep und substr bearbeiten
gt substr(x23)[1] AB
Hier wird ein Substring aus x erzeugt Der erste Parameter gibt den Start und der letzte das Endedes Substrings in der urspruumlnglichen Zeichenkette an In diesem Fall werden die Buchstaben ABausgewaumlhlt Wenn der Start- und der Endwert gleich sind wird nur ein Buchstabe ausgewaumlhlt
gt substr(x22)[1] A
95 Vektoren
Ein Vektor ist ein Datentyp in R mit dem man eine Reihe anderer Datentypen zB numeric odercharacter enthaumllt Ein Vektor ist ein eindimensionales Array Hier ein Beispiel aus der Genetik einVektor mit SNPs von 150 Tieren
gt s1[1] GG GG GG GG GG AC GG AA GG AC GG AG AG AC AG ACGG GG AC GG AA GG GG AG CC AA GG AC AA GG AG AC GG
7 httpdewikibooksorgwikiGNU20R3A20paste8 httpdewikibooksorgwikiGNU20R3A20nchar
30
Vektoren
GG AG GG[37] GG GG AG GG AG GG AG AC AG AG GG AG GG AA GG AGAG GG AA AC AG GG AG GG AA AC GG GG AA GG GG GG AGGG AG AG[73] AA AC GG AG AG AA AG AG AG AG AA AA AG AC GG GGCC AA GG GG AC CC GG AC AG AC AC GG AG GG AC AG AAAG GG CC[109] AG GG AG AG AG AC AG AA AC AA AC AA AG AG GG GG
GG AG GG GG AG GG AG GG AG AA GG GG AA AC AG AG GGAG AG AA[145] AA GG AG AC AA GG
Auf die Elemente eines Vektors kann man wie folgt zugreifen
gt s1[1][1] GGLevels AA AC AG CC GG
Hier wurde ein einzelnes Element das erste Element des Vektors ausgewaumlhlt Im Gegensatz zu denmeisten anderen Programmiersprachen wird das erste Element eines Vektors in R nicht mit 0 sondernmit 1 angesprochen Zusaumltzlich werden immer die Level bei Vektoren ausgegeben die Faktorenenthalten
gt s1[315][1] GG GG GG AC GG AA GG AC GG AG AG AC AGLevels AA AC AG CC GG
Durch die Angabe eines Bereichs koumlnnen auch mehrere Elemente ausgewaumlhlt werden In diesemBeispiel wurden die Elemente 3 bis 15 ausgewaumlhlt
gt class(s1)[1] factorgt dim(s1)NULLgt length(s1)[1] 150
Mit class findet man heraus um was fuumlr einen Vektor es sich handelt hier ist es ein Vektor derFaktoren enthaumllt Der Befehl dim liefert uumlberraschender Weise bei Vektoren null die Laumlnge einesVektors laumlsst sich aber mittels length bestimmen hier enthaumllt der Vektor 150 Elemente
gt levels(s1)[1] AA AC AG CC GG
Wenn man einen Vektor mit Faktoren hat kann man mittels levels die unterschiedlichen Elementeextrahieren und in Kombination mit length die Anzahl der Elemente ermitteln
length(levels(s1))[1] 5
Wenn man herausfinden moumlchte wie oft die einzelnen Faktoren im Vektor vorkommen kann manden Befehl table verwenden
31
Daten in R
gt table(s1)s1
AA AC AG CC GG22 22 46 4 56
32
10 Manuelle Dateneingabe
Eine einfache Moumlglichkeit manueller Dateneingabe ist die Funktion c1
c2(5348625013)
liest die Zahlenfolge 5 3 4 8 6 25 0 13 ein Wichtig ist hierbei dass als Dezimaltrennzeichenein Punkt stehen muss
Der eben genannte Aufruf erzeugt nur die Ausgabe
[1] 50 30 40 80 60 25 00 13
101 Eingabe von logischen Werten
abc lt- c3(TRUEFALSETRUEFALSEFALSETFTT)
speichert die logischen Werte in abc TRUE kann immer mit T und FALSE mit F abgekuumlrzt werden
1 httpdewikibooksorgwikiGNU20R3A20c
33
11 Umgang mit Datensaumltzen (ErstellenAuswaumlhlen und Filtern)
35
12 Datenimport und -export
Der Datenaustausch zwischen verschiedenen Anwendungen ist oft eine muumlhsame Angelegenheit mitvielen Fallstricken Er erfordert daher einiges an Aufmerksamkeit und Sorgfalt R kann zahlreicheFormate einlesen Welches Format im Einzelfall am geeignetsten ist muss oft ausprobiert werdenbesonders wenn das native Format eines Programmes nicht unterstuumltzt wird So wird zB dasDateiformat der Statistiksoftware Statistica von R nicht unterstuumltzt Allerdings bietet Statistica dieMoumlglichkeit die Daten unter anderem als SPSS-Datei oder als CSV-Datei1 (via Text File) zuexportieren die von R eingelesen werden koumlnnen
121 Import
1211 Import aus Textdateien
Mit der readcsv2 readtable3 und verwandten Funktionen koumlnnen Daten aus Textdatei-en (txt) importiert werden readtable4 ist die Basisfunktion zum Import von Textdateienreadcsv5 und readcsv26 sowie einige Funktionen mehr sind Anpassungen an haumlufig auftre-tenden Faumllle CSV7 ist zB das Standardexportformat fuumlr viele Tabellenkalkulationen und andereAnwendungen unterscheidet sich aber je nachdem ob als Dezimaltrennzeichen der Punkt (englischerSprachraum) oder das Komma (bei uns) verwendet wird
Legen Sie eine txt-Datei mit folgendem Inhalt an indem Sie die folgenden Zeilen markieren kopierenund in einen Texteditor einfuumlgen
Geschlecht Alter Gewicht Groessem 28 80 170w 18 55 174w 25 74 183m 29 101 190m 21 84 185w 19 74 178w 27 65 169w 26 56 163m 31 88 189m 22 78 184
1 httpdewikipediaorgwikiCSV-Datei2 httpdewikibooksorgwikiGNU20R3A20readcsv3 httpdewikibooksorgwikiGNU20R3A20readtable4 httpdewikibooksorgwikiGNU20R3A20readtable5 httpdewikibooksorgwikiGNU20R3A20readcsv6 httpdewikibooksorgwikiGNU20R3A20readcsv7 httpdewikipediaorgwikiCSV-Datei
37
Datenimport und -export
Speichern Sie diese Textdatei unter dem Namen bdquoTabellentesttxtldquo auf Ihre Festplatte Nun koumlnnenSie die Tabelle mit der Funktion readtable()8 in R einlesen
gt meinetabelle lt- readtable9(PfadzurTabelletxt header=TRUE)
Das Argument header=TRUE besagt dass die erste Zeile der Datei keine Daten enthaumllt sondern dieBezeichnungen (Variablen) der Tabellenspalten angibt
Die Tabelle ist nun in dem Objekt meinetabelle vorhanden Sie koumlnnen sie sich ansehen indem Sieeingeben
gt meinetabelle
Geschlecht Alter Gewicht Groesse1 m 28 80 1702 w 18 55 1743 w 25 74 1834 m 29 101 1905 m 21 84 1856 w 19 74 1787 w 27 65 1698 w 26 56 1639 m 31 88 18910 m 22 78 184
In unserem Beispiel waren die Daten jeweils mit einem Leerzeichen getrennt Haben Sie eineTextdatei in welcher die Daten durch einen Tab getrennt sind muumlssen sie die readtable-Funktionum das Argument sep=ldquotldquo erweitern
gt meinetabelle lt- readtable10(PfadzurTabelletxt sep=ldquotldquo header=TRUE)
Wurden die Daten von einer Tabellenkalkulation wie zB Excel aber auch aus Statistikprogrammenals CSV-Datei (comma separated values) exportiert dann muss noch unterschieden werden welcheSchreibkonvention verwendet wurde Bei englischsprachiger Software wird der Punkt als Dezimalt-rennzeichen verwendet und das Komma um die verschiedenen Werte voneinander zu trennen Indiesem Fall ist readcsv11 zu verwenden Sofern das Komma als Dezimaltrennzeichen dientund der Strichpunkt () die einzelnen Werte voneinander trennt dann kommt readcsv212 zumEinsatz
Tip
8 httpdewikibooksorgwikiGNU20R3A20readtable11 httpdewikibooksorgwikiGNU20R3A20readcsv12 httpdewikibooksorgwikiGNU20R3A20readcsv
38
Import
Bei CSV-Dateien kommt es leicht zu Problemen wenn Textvariablen zB mit Kommentarenvorhanden sind Diese koumlnnen das jeweilige Trennzeichen enthalten Beim Import kommt es danndazu dass nachfolgende Felder mit falschen Inhalten gefuumlllt werden Nicht jedes importierendeProgramm gibt eine Fehlermeldung aus obwohl mehr Felder als erwartet auftreten Das gilt auch fuumlrREine Abhilfe besteht darin ein alternatives Trennzeichen zu verwenden das garantiert nicht in denTextvariablen auftritt zB (wenn es sich nicht zufaumlllig um Emailadressen handelt) Allerdings istdas nicht mit allen Programmen moumlglich Eine weitere Moumlglichkeit besteht darin Stringvariablen inAnfuumlhrungszeichen zu setzen Auch das ist nicht immer moumlglich Im unguumlnstigsten Fall muumlssen dieTextvariablen nachbearbeitet und das jeweilige Trennzeichen ersetzt werden Auf jeden Fall ist eserforderlich die Daten nach dem Import auf Fehler zu kontrollierenBei R fuumlhrt das zusaumltzliche Datenfeld dazu dass ein zusaumltzlicher Fall angelegt wird der durchgaumlngigmit fehlenden Werten (NA) belegt ist Mit dim(x)13 kann einfach uumlberpruumlft werden ob mehr Faumllleals erwartet vorliegen
1212 Import aus dem Zwischenspeicher Clipboard
Analog dem Import aus Textdateien kann statt einer File bei readtable auch stdin() als Quelleangegeben werden In diesem Fall wartet R auf Texteingaben Wenn sich im Zwischenspeicher eineTabelle befindet kann diese per Copy and Paste uumlbernommen werden
gt a lt- readtable(file=stdin()header=T)
0 Name Geschlecht Lieblingsfarbe R wartet aufEingabe
1 Hans m gruen
2 Waldemar w blau
3 Tanja m rosa
4 Return inleerer Zeile schlieszligt Eingabe ab
gt a
Name Geschlecht Lieblingsfarbe
1 Hans m gruen
2 Waldemar w blau
13 httpdewikibooksorgwikiGNU20R3A20dim
39
Datenimport und -export
3 Tanja m rosa
Dies ist oft die einfachste Variante des Imports wenn aus Browsern oder PDF-Files Tabellenuumlbernommen werden sollen die bereits hinreichend formatiert sind
TipWenn die Daten aus einer HTML-Seite uumlbernommen werden ist die Verwendung des Web-browser Firefox14 in Verbindung mit dem Add-On Table2Clipboard15 hilfreich Wenn dieStandardeinstellung mit Tabulator-Trennung Probleme macht funktioniert zum Beispiel dieParameterkombination row-seperator n column-seperator in Table2Clipboard undreadtable(file=stdin()header=Tdec=sep=) in R
1213 Import aus MySQL
Um aus R auf eine MySQL-Datenbank zugreifen zu koumlnnen muss das Paket RMySQL16 installiertsein Es benoumltigt zusaumltzlich das Paket DBI17 (und unter Windows die Datei libmySQLdll diein MySQL enthalten ist)
library18(RMySQL) package RMySQL ladendrv = dbDriver(MySQL) MySQL verwenden
Verbinde mit einer Datenbankcon = dbConnect(drvuserpassworddbname) Verbinde mit einer Datenbank und verwende BenutzerPasswort ausder Datei mycnfcon = dbConnect(drvdbname) Andere Moumlglichkeitcon lt- mysqlNewConnection19(drvdbnameuserpassword)
listet alle Tabellen aufdbListTables20(con)
Anfragers lt- dbGetQuery21(conSELECT COUNT() FROM mytable)
Hilfreich sind auch die Funktionen mysqlReadTable22 und mysqlWriteTable23
1214 Import aus SPSS
Sie koumlnnen Ihre vorliegenden SPSS-Daten in R importieren Hierzu muumlssen Sie allerdings zunaumlchstein Zusatzpaket in R installieren Funktionen zum Datenimport aus SPSS bieten beispielsweise diePakete foreign und Hmisc Sie installieren also zunaumlchst eines der Zusatzpakete per
14 httpwwwmozillacom15 httpdafizillasourceforgenettable2clip16 httpcranr-projectorgwebpackagesRMySQLindexhtml17 httpcranr-projectorgsrccontribDescriptionsDBIhtml22 httpdewikibooksorgwikiGNU20R3A20mysqlReadTable23 httpdewikibooksorgwikiGNU20R3A20mysqlWriteTable
40
Import
installpackages24(foreign dependencies = TRUE)
oder
installpackages25(Hmisc dependencies = TRUE)
Das Argument dependencies=TRUE besagt dass alle weiteren relevanten Zusatzpakete die eventuellfuumlr foreign und Hmisc benoumltigt werden direkt mitinstalliert werden Bevor sie die Funktionen derZusatzpakete nutzen koumlnnen muumlssen Sie diese aktivieren per
library26(foreign)oderlibrary27(Hmisc)
Der Import kann nun uumlber die folgenden Funktionen erfolgen
bull readspss()28 (aus dem foreign-Paket)bull spssget()29 (aus dem Hmisc-Paket)
Dies geschieht mit der readspss-Funktion beispielsweise so
meinspss lt- readspss30(derpfadzurSPSSdateisav)
Beachten Sie dass Sie den kompletten Pfad zur SPSS-Datei angeben muumlssen Auf Windows-Systemen werden Pfadangaben normalerweise mit einem Backslash () dargestellt Dies funktioniertin R nicht da der Backslash in R ein Steuerungszeichen ist Die uumlbliche Schreibweise in R mitdem Schraumlgstrich () funktioniert aber auch unter Windows einwandfrei Falls unter Windows derBackslash beibehalten werden soll muss jeder Backslash durch zwei Backslashes ersetzt werden(zB CPfadzurSPSSdateisav)
Sind in der SPSS-Datei nominale Daten vorhanden deren numerische Auspraumlgungen mit Labels hin-terlegt sind (zB bei einer Variable bdquoGeschlechtldquo sind die Auspraumlgungslabels 0=weiblich 1=maumlnnlichgesetzt) so werden die ausgeschriebenen Labels als Variablenwert in R uumlbernommen
Wenn Sie moumlchten dass nicht die Variablenlabels sondern die numerischen Auspraumlgun-gen (zB Geschlecht = 01) uumlbernommen werden muss der Befehl um das Argumentusevaluelabels=FALSE erweitert werden
meinspss lt- readspss31(pfadzurSPSSdateisav usevaluelabels=FALSE)
Jetzt sind in dem Objekt meinspss die Daten der SPSS-Datei vorhanden Sie koumlnnen sie sich ansehenindem Sie eingeben
28 httpdewikibooksorgwikiGNU20R3A20readspss29 httpdewikibooksorgwikiGNU20R3A20spssget
41
Datenimport und -export
meinspss
TipFuumlr Variablennamen mit Umlauten koumlnnen beim Import aus SPSS-Dateien Probleme auftretenDeshalb ist es moumlglicherweise notwendig vor dem Import die Sprachoptionen richtig zu setzen (zBSyssetlocale(locale=de_DEISO8859-15) )readspss uumlbernimmt auch die in SPSS vergebenen Variablenlabels allerdings als speziellesAttribut Diese koumlnnen uumlber attr(meinspssvariablelabels) als Vektor ausgegebenund entsprechend als Titel fuumlr Tabellen und Graphiken weiter verwendet werden ( Als Beispiel wiesich SPSS-Labess in R importiert lassen dient dieses Skript32 )
1215 Import aus XML
1216 Import aus Excel-Dateien und CSV-Dateien
Excel Dateien koumlnnen auf verschiedenen Wegen in R importiert werden Welcher Weg fuumlr denBenutzer der Richtige ist haumlngt von folgenden Bedingungen ab
bull Excel Versionbull Umfang der Datenbull Strukturierung der Daten
Excel ist sehr weit verbreitetes Programm zur Verarbeitung von Tabellen Es gibt diverse Versionendieser Software und durch die kontinuierliche Weiterentwicklung von Excel gibt es auch verschiedenVersionen des Excel Dateiformats Fuumlr die verschiedenen Excel Formate gibt es Importmoumlglichkeitenin R zB via eines Datenbanktreibers
Neben diesen Importmoumlglichkeiten gibt es den oft praktikableren Weg die Datei im Excel Format ineine CSV (Comma-Separated Values) Datei umzuwandeln Dazu kann man Excel selbst aber auchandere Programme wie Open Office verwenden Der Nachteil dieses Weges ist dass man nur eineTabelle umwandeln kann Oft bestehen Excel Dateien aus mehreren Tabellen Nach der Umwandlungkann man die CSV Datei in R wie folgt einlesen
tt = readcsv(tcsv)
Hier wird die Datei tcsv aus dem aktuellen Arbeitsverzeichnis in die Variable tt vom Typ listeingelesen Alternativ kannman auch folgende Anweisung verwenden
tt = readtable(tcsv sep=)
Die Option sep legt fest welches Zeichen R als Zelltrenner in der Datei interpretieren soll WeitereOptionen sind unter GNU R readtable33 zu finden
32 Kapitel 551 auf Seite 23733 httpdewikibooksorgwikiGNU20R3A20readtable
42
Export
122 Export
1221 HDF5
Siehe von httpcranr-projectorgwebpackageshdf5hdf5pdf
Import von HDF-libinstallpackages(hdf5)library(hdf5)(m lt- cbind(A = 1 diag(4)))ll lt- list(a=110 b=letters[18])l2 lt- list(C=c l=ll) PP lt- pi Speichern der Objekte als HDF Dateihdf5save(ex1hdf mPPlll2) Entfernen der Objekte aus dem R-Workspacerm(mPPlll2) and reload them Laden der Objekte aus der HDF Dateihdf5load(ex1hdfverbosity=3)m read from ex1hdf buglet dimnames droppedstr(ll)str(l2)
43
13 Daten laden und speichern
45
14 Daten laden
Daten koumlnnen mit load1(Dateiname) geladen werden
Wenn die Datei im Internet liegt muss sie mit Hilfe der url()2-Funktion geladen werden
gt load(url(httpPfadzuDateiRData)) Beispiel-URL
1 httpdewikibooksorgwikiGNU20R3A20load2 httpdewikibooksorgwikiGNU_R3A_url
47
15 Daten speichern
Mit der Funktion ls()1 listet R alle vorliegenden Variablen auf
151 Arbeitsspeicher speichern
Mit saveimage2(dateinameRData) wird das vorliegende Datenframe (alle Variablen)als sichtbare Datei im working directory3 (getwd()4) gespeichert (Wenn man nur saveimage()5
ausfuumlhrt wird das Datenframe als RData gespeichert und ist dann im Dateibrowser unsichtbar)
Wenn man dann R wieder startet wird diese Datei automatisch geladen Unter Linux scheint esnotwendig zu sein den Arbeitsspeicher per Hand zu laden Zunaumlchst muss man in das Verzeichniswechseln in dem die Datei liegt Diese wird dann mittels load(DateinameRData) geladen
152 einzelne Objekte speichern
Wenn nur einzelne Objekte gespeichert werden sollen wird die save-Funktion angewandt Mitdem list-Parameter werden die gewuumlnschten Objekte angegeben welche in die Datei filegespeichert werden sollen
save(file=UsersprodunisworkingREinzelobjektRDatalist=Objekt) Beispiel
1 httpdewikibooksorgwikiGNU20R3A20ls2 httpdewikibooksorgwikiGNU20R3A20saveimage3 httpdewikibooksorgwikiGNU_R3A_Arbeitsverzeichnis4 httpdewikibooksorgwikiGNU20R3A20getwd5 httpdewikibooksorgwikiGNU20R3A20saveimage
49
16 Arbeitsverzeichnis
Das aktuelle Arbeitsverzeichnis kann per getwd()1 angezeigt werden Mit dem Befehl dir()2
werden die Dateien des aktuellen Arbeitsverzeichnisses angezeigt
Moumlchte man das Arbeitsverzeichnis wechseln so benutzt man den Befehl setwd()3
setwd4(UsersprodunisR) Beispiel
Auf Dauer kann es einfacher sein ein eigenes Arbeitsverzeichnis beim Startvorgang einzustellenFuumlr diese Faumllle gibt es die Datei Rprofilsite Dieser muss nur eine letzte Zeile (gefolgt von einemZeilenumbruch) mit dem Befehl setwd hinzugefuumlgt werden
1 httpdewikibooksorgwikiGNU20R3A20getwd2 httpdewikibooksorgwikiGNU20R3A20dir3 httpdewikibooksorgwikiGNU20R3A20setwd
51
17 Daten selektieren
53
18 Daten auswaumlhlen
Sehr oft moumlchte man nicht alle Daten aus einer eingelesenen Datei verarbeiten sondern nur Teiledavon Hier bietet R elegante Loumlsungen basierend auf Rs sehr flexiblen Parameterverarbeitung
Problem Ich habe ein Tabelle und moumlchte nur diese Tabelle reduzieren Es sollen nur die Spaltenausgewaumlhlt werden die mit den Buchstaben XX anfangen
Loumlsung Hier ein Beispiel
gt dim(bt)[1] 150 63983
Dies ist meine Originaltabelle
gt r = colnames(bt prefix=Row)
Die Variable r enthaumllt alle Spaltennamen aus der Originaltabelle
gt rr = grep(Rowr)
Die Variable r enthaumllt alle Idizies der Namen die mit Row beginnen Nicht die Namen selbst
gt snp = bt[rr]gt dim(snp)[1] 150 52727gt snp[1515]
Row_14496 Row_14497 Row_14498 Row_14499 Row_145001 AG AC AG AG AG2 AA AC GG AG AG3 AG AC GG AA AA4 AA AC AG AA AG5 AA AA GG AG AG
Zuletzt wird die Tabelle reduziert mit Hilfe der mittels grep gefundenen Indizies
55
19 Matrix- und Listenoperationen
191 Matrix- und Listenoperationen
1911 Matrizen
Die wichtigsten Befehle fuumlr Matrizen in Kurzform
t(matrix) transponierte matrixeigen(matrix)$val Eigenwerteeigen(matrix)$vec Eigenvektorencov(swiss) Kovarianzcor(swiss) Korrelationdiag(Eigenwerte) Diagonale der Eigenwerte Matrixmultiplikation
1912 Listen
Fuumlr Listen stehen die Funtionen lapply bzw sapply zur Verfuumlgung Dabei wird auf jedes Elementeines geordneten Objektes eine definierbare Funktion angewandt
Beispiel In dem dataframe cars sind die beiden metrischen Variablen speed (Geschwindigkeit)und dist (Distanz bis zum Stillstand) enthalten Wir wollen nun zu jeder Variable das arithmetischeMittel
Rgt lapply ( cars function(x) mean(x) )$speed[1] 154
$dist[1] 4298
Generell gibt lapply eine Liste mit den resultierenden Objekten aus
Rgt class ( lapply ( cars function(x) mean(x) ) )[1] list
Die Funktion sapply fasst die daraus resultierenden Listenelemente zusaumltzlich zu einem einzelnenObjekt zusammen
57
Matrix- und Listenoperationen
Rgt sapply ( cars function(x) mean(x) )speed dist
|1540 4298Rgt class ( sapply ( cars function(x) mean(x) ) )[1] numeric
Bei komplexeren Objekten (und insbesondere bei Datumsobjekten der Klassen POSIXt) trittzuweilen das Problem auf dass bei der Verwendung von lapply die Klassendefinition verlorengeht Dieses Problem kann durch folgender Aufruf geloumlst werden
docall( c lapply ( liste function (x) x$datum) ) )
58
20 Benutzeroberflaumlchen und Erweiterungen
R kann von anderen ProgrammenProzessen Befehle empfangen und Ergebnisse zuruumlckgeben Da-durch ist es moumlglich graphische Benutzeroberflaumlchen fuumlr R zu schreiben oder in andere Anwendungenzu integrieren
59
21 Graphische Benutzeroberflaumlchen
Die Entwicklung grafischer Benutzeroberflaumlchen fuumlr GNU R steckt noch in den Anfaumlngen Eine kom-plette Liste der verschiedenen Projekte findet sich unter httpwwwr-projectorgGUIDie unten gelisteten Projekte verfolgen das Ziel eine mehr oder weniger vollstaumlndige Benutzerober-flaumlche zu entwickeln (im Gegensatz zB zu reinen Skript-Editoren)
211 JGR (Jaguar)
JGR1 wird von der Uni Augsburg entwickelt JGR ist eine einfache grafische Benutzeroberflaumlche fuumlrR geschrieben in Java Nuumltzlich sind hier vor allem der Paketmanager zum Laden von Zusatzpaketenund der Objektbrowser welcher die vorhandenen Daten uumlbersichtlich ordnet und auch bearbeitenlaumlsst Dem Programmmenuuml koumlnnen eigene Funktionen hinzugefuumlgt werden Eine Anleitung hierzubefindet sich in der Paketbeschreibung
JGR benoumltigt Sun 15 SDK und muss fuumlr LinuxUnix selbst kompiliert werden
212 R Commander
R Commander ist eine Menu-Oberflaumlche von John Fox fuumlr Anfaumlnger Umsteiger und Mausbenutzerdie sich schwer damit tun die Kommandos von R zu lernen
httpsocservmcmastercajfoxMiscRcmdr
R Commander kann als Bibliothek unter R geladen werden Man benoumltigt also kein Java und manmuss nichts kompilieren
213 RKWard
RKWard dewikipediaorgwikiRKWard2 ist ein GUI fuumlr R unter KDE 4 Es ist derzeit fuumlr Li-nuxUnix und Windows verfuumlgbar Enthalten sind unter anderem ein Paketmanager Skript-EditorDaten-Editor Objektbrowser und Hilfebrowser Neue Dialoge zu Statistikfunktionen lassen sich uumlberPlugins hinzufuumlgen
1 httpstatsmathuni-augsburgdeJGR2 httpdewikibooksorgwiki
61
Graphische Benutzeroberflaumlchen
214 Sciviews-R
Sciviews ist eine Verbindung von mehreren Anwendungen die das Arbeiten mit R erleichtern sollenSciviews ist derzeit nur unter Windows lauffaumlhig
215 RStudio
RStudio haumllt unter einer GUI Console und mehrere Skriptfenster (Source) zum Einen sowie Works-paceinhalte History und Grafikfenster Workingdirectory aktivepassive Pakete und ein Hilfefensterzum Anderen gemeinsam parat Das Grafikfenster haumllt eine Historyfunktion und einfache Export-moumlglichkeiten vor Aus der History kann sowohl in die Console als auch das Skriptfenster kopiertwerden RStudio ist fuumlr Windows Mac und Linux verfuumlgbar
62
22 Sonstige Schnittstellen
221 R in Emacs ESS
Fuumlr den Texteditor Emacs dewikipediaorgwikiEmacs1 gibt es mit ESS (Emacs Speaks Statistics)bereits eine fertige All-In-One-Loumlsung
Abb 1
Neben Standardfunktionen (automatische Codeformatierung kontextabhaumlngige Hilfe) besteht derHauptvorteil darin dass in einem Fensterbereich programmiert werden kann und sich dann flexibelund schnell einzelne Befehle Funktionen Teile oder ganze Programme an R senden lassen Ergeb-nisse von R werden in diesem Fall in einem zweiten Fensterbereich in Emacs oder der ausgewaumlhltenGrafikumgebungen ausgeben
Auf diese Weise ist es zB auch moumlglich R-Prozesse auf entfernten Rechnern zu steuern
1 httpdewikibooksorgwiki
63
Sonstige Schnittstellen
Naumlheres zu ESS findet sich unter httpessr-projectorg
TipWenn Sie ESS unter Mac OS X mit dem fuumlr die GUI-Version standardmaumlssig verwendeten Quartz-Window-Manager verwenden wollen dann empfiehlt sich die Installation und Einbindung des PaketsCarbonEL und setzen von options(device=quartz)
64
23 Automation und dynamischeDokumenterstellung
65
24 Batchmode
Mit R kann der gesamte Funktionsumfang auch automatisiert werden Dazu wird lediglich eineSource-Datei mit Programmcode benoumltigt die dann zB folgendermaszligen unter LINUX zurAusfuumlhrung gebracht werden kann
bashgt R --vanilla --slave lt verzeichnismeine_sourcefiler
Auf diese Weise lassen sich ohne komplizierte Navigation durch Menuumls usw aktuelle Graphikenerstellen oder Berechnungen durchfuumlhren und (zB via cron) automatisieren
67
25 Dynamische Dokumenterstellung mit demPaket (S-odf-)Weave
Statistiken sind kein Selbstzweck Zumeist steht am Ende statistischer Auswertungen ein Bericht odereine wie auch immer geartete Veroumlffentlichung der Ergebnisse Mit dem Paket Sweave ist es moumlglichden Prozess der Statistischen Auswertung und der Dokumentation dieser Arbeit in einem Workflowzu behandeln Die Idee ist dass R-Befehle in ein Dokument eingefuumlgt werden und durch statistischeAuswertungen ersetzt werden Dadurch lassen sich leicht aktualisierbare Berichte erstellen oderForschungsarbeiten schon waumlhrend der statistischen Auswertung erstellen Sweave ist auch ein groszligerSchritt in Richtung replizierbarer statistischer Auswertungen da sich Daten Auswertungsprozedurenund Auswertungsergebnisse in einem Dokument ablegen lassen
Derzeit ist dies fuumlr drei Dokumentformate moumlglich odf tex und html
Open document Format (odt) ist das Standardformat der freien Textverarbeitung Open Office bzwLibreOffice
Tex ist ein relativ altes und etabliertes Textsatzsystem das vom gewohnten What-you-see-is-what-you-get zu Gunsten des What-you-see-is-what-you-mean-Paradigmas abweicht Text wird hier vonAnweisungen und Tags umgeben die dem System sagen wie ein bestimmter Textteil zu setzen istDadurch koumlnnen waumlhrend des Schreibens Layout-Fragen im Hintergrund bleiben
odfWeave ist ein eigenes Paket das (noch) nicht Teil der Standardinstallation ist und muss manuellnachinstalliert werden
gt installpackages1(odfWeave dependencies=TRUE)gt library2(utils) Laden der neuinstallierten Paketegt library(odfWeave)
Sweave ist Teil des utils-Paketes und muss ggf ebenfalls installiert werden
251 Grundprinzipien dynamischer Dokumenterstellung
Die Idee hinter (S)Weave ist folgende Wir erstellen ein Dokument An bestimmten Stelle geben wireine Anweisung dass eine Statistik oder Graphik eingefuumlgt werden soll Bei Bedarf lassen wir R dasDokument berechnen und erhalten ein Dokument mit Tabellen Diagrammen usw
69
Dynamische Dokumenterstellung mit dem Paket (S-odf-)Weave
Abb 2
Die Anweisungen an R werden bei Verwendung des Sweave-Pakets typischerweise in einercharakteristischen Form gegeben die der Noweb-Syntax folgen Dabei handelt es sich um Bloumlcke(genannt Chunks) mit folgender Syntax
ltltBlocknameAufrufparameter gtgt= 1 Startteil
R Befehle 2 Anweisungenprint(iris)
3 Schlussteil
Zu beachten ist die dreiteilige Struktur Der Startteil hat die Form ltlt gtgt der Anweisungsteilbesteht aus gewoumlhnlichen R Befehlen und zum Schluss jedes Chunks steht als charakteristischesErkennungszeichen ein
252 R und Open Office
Oumlffnen Sie ein Open-Office-Dokument fuumlgen Sie an einer beliebigen Stelle das folgende Chunk ein
ltltUnser_erster_Testoutputecho=FALSEgtgt=print(iris) Ausgabe des Datensatz iris
Speichern Sie das neu erstellte Dokument zum Beispiel unter dem Namen rofficeodt
In R koumlnnen Sie jetzt mit dem Befehl
70
R und Latex
gt odfWeave3(pfadzurdateirofficeodtpfadzurdateirofficeoutodt)
alle Chunks in dem Office Dokument rofficeodt durch die entsprechenden Berechnungenersetzen lassen In unserem Fall sollte das neu erstellte Dokument rofficeoutodt nach demOumlffnen in Open Office den Ausdruck des Iris-Datensatzes enthalten Damit duumlrfte das wesentlichePrinzip deutlich geworden sein Da Open Office auch problemlos in das derzeit noch verbreitete doc-Format exportieren kann bietet odfWeave die entscheidende Schnittstelle fuumlr alle R-Nutzerinnendie auf den Austausch mit WindowsMS Office-Produkten angewiesen sind
Bleibt der Vollstaumlndigkeit halber noch der Parameter echo zu erklaumlren echo=TRUE haumltte zur Folgegehabt dass die Anweisung print(iris) mit in das Dokument rofficeoutodt geschriebenworden waumlre
253 R und Latex
Zur Erzeugung von (La)Tex-Dokumenten geht man identisch vor wie bei odf-Dateien In einetex-Datei werden chunks integriert und in einem zweiten Schritt mit R durch die Ergebnisse ersetztKonventional enden Tex-Sweave-Dateien allerdings mit der Endung Rnw (fuumlr R - Noweb) und stattodfWeave kommt Sweave zum Einsatz
gt Sweave4(texfileRnw)
generiert die Datei texfiletex im selben Verzeichnis Diese kann dann mit Latex in verschiedensteFormate wie Postscript oder PDF gebracht werden
Unter LINUX laumlsst sich der gesamte Arbeitsschritt folgendermaszligen automatisieren
bashgt echo library(utils) Sweave(PfadDateinameRnw) | R--no-save --no-restore bashgt latex PfadDateinametex
254 Dynamische Webseiten mit R
Das Paket R2HTML implementiert den Sweave-Workflow fuumlr Html-Seiten und ermoumlglicht damitweltweit abrufbare und automatisch aktualisierte statistische Auswertungen
255 Ausblick
So weit die grundlegende Funktionsweise von odfWeave und Sweave Der eigentliche Clou ist jedochsicher dass auf diese Weise automatisiert Graphiken und formatierte Tabellen eingebunden werdenkoumlnnen was in Kuumlrze in einem der naumlchsten Kapitel ausgefuumlhrt werden wird
71
Dynamische Dokumenterstellung mit dem Paket (S-odf-)Weave
Bis dahin sind die entsprechenden Hilfeseiten zu empfehlen
gt Sweavegt odfWeave
(Und wer sich schon einarbeitet kann natuumlrlich auch diesen Artikel ergaumlnzen (- )
256 Weblinks
bull odfWeave-Manual (PDF englisch)5
bull Wikipedia-Artikel Open Document Format (odf odt)6
bull Wikipedia-Artikel Open Office7
bull Wikipedia-Artikel TeX8
5 httpcranatr-projectorgwebpackagesodfWeaveodfWeavepdf6 httpdewikipediaorgwikiOpenDocument7 httpdewikipediaorgwikiOpen20Office8 httpdewikipediaorgwikiTeX
72
Teil III
Statistik mit R
73
26 Diagramme und Grafiken erzeugen
Mit R koumlnnen die verschiedensten Diagramme und Grafiken erstellt werden
261 Funktionen zum Erstellen von Diagrammen
bull barplot()1 -- Erstellen von Saumlulendiagrammenbull boxplot()2 -- Erstellen von Boxplots (beinhaltet Maximalwert Minimalwert Median Quartile
Ausreiszliger)bull contour()3 -- Erstellen von Konturdiagrammen plotten von Isolinienbull dotchart()4 -- Erstellen von Punktediagrammenbull forestplot5 - (aus dem Zusatzpaket rmeta) erzeugt ein so genanntes Forest Plot zusammen
mit einer Texttabellebull hist()6 -- Erstellen von Histogrammenbull map7 - (aus dem Paket maps und mapdata) erstellt Karten von Laumlndern Kontinenten und der
Weltbull metaplot8 - (aus dem Zusatzpaket rmeta) erzeugt ein so genanntes Forest Plot (Meta-
Analyse-Plot) welches im Rahmen von Metaanalysen gaumlngig istbull par()9 -- Setzen von grafischen Parameternbull persp()10 -- Erstellen von Dreidimensionalen Abbildungenbull pie()11 -- Erstellen von Kreisdiagrammenbull plot()12 -- Standardfunktion zum Erstellen von Diagrammenbull title()13 -- Beschriftung von Diagrammen
1 httpdewikibooksorgwikiGNU_R3A20barplot2 httpdewikibooksorgwikiGNU_R3A20boxplot3 httpdewikibooksorgwikiGNU_R3A20contour4 httpdewikibooksorgwikiGNU_R3A20dotchart5 httpdewikibooksorgwikiGNU_R3A20forestplot6 httpdewikibooksorgwikiGNU_R3A20hist7 httpdewikibooksorgwikiGNU20R3A20map8 httpdewikibooksorgwikiGNU_R3A20metaplot9 httpdewikibooksorgwikiGNU_R3A20par10 httpdewikibooksorgwikiGNU_R3A20persp11 httpdewikibooksorgwikiGNU_R3A20pie12 httpdewikibooksorgwikiGNU_R3A20plot13 httpdewikibooksorgwikiGNU_R3A20title
75
Diagramme und Grafiken erzeugen
262 Funktionen zum Erstellen zusaumltzlicher grafischer Elemente
bull colors()14 zeigt eine Uumlbersicht aller Standardfarben genauergesagt ihrer Farbwoumlrter (blue redgreen ) an
bull lines(xy)15 - Zum Zeichnen von beliebigen Linienzuumlgen und Funktionenbull polygon(xy)16 - erzeugt ein (beliebiges) Vieleck dass schraffiert oder mit Farbe gefuumlllt werden
kannbull plotmath17 - fuumlgt einem Plot mathematische Symbol hinzu
263 Grafiken speichern
bull jpeg()18 - speichert die Grafik als jpeg-Datei abbull png()19 - speichert die Grafik als png-Datei abbull pdf()20 -- speichert eine Grafik als PDF-Datei abbull postscript()21 -- Speichert die Grafikausgabe in eine Postscript-Dateibull savePlot()22 -- Speichert die aktuelle Grafik in eine Dateibull devSVG()23 -- speichert eine Grafik als SVG-Datei ab Dazu ist das Zusatzpaket RSvgDevice
erforderlich
264 siehe auch
bull Grafikbeispiele24
265 Literatur
bull Paul Murrell (2005) R Graphics Chapman amp Hall 301 Seiten ISBN 158488486X
266 Weblinks
bull Beispiele von Benutzer Thire in der Wikipedia25
14 httpdewikibooksorgwikiGNU20R3A20colors15 httpdewikibooksorgwikiGNU_R3A_lines16 httpdewikibooksorgwikiGNU_R3A_polygon17 httpdewikibooksorgwikiGNU20R3A20plotmath18 httpdewikibooksorgwikiGNU20R3A20jpeg19 httpdewikibooksorgwikiGNU20R3A20png20 httpdewikibooksorgwikiGNU_R3A20pdf21 httpdewikibooksorgwikiGNU_R3A20postscript22 httpdewikibooksorgwikiGNU_R3A20savePlot23 httpdewikibooksorgwikiGNU_R3A20devSVG24 Kapitel 49 auf Seite 187
25 httpdewikipediaorgwikiBenutzer3AThire2FBilder23Mathematische_Grafiken
76
Weblinks
bull CategoryCreated_with_R26 in Wikimedia Commonsbull R Graphics by Paul Murrell27
26 httpcommonswikimediaorgwikiCategoryCreated_with_R27 httpwwwstataucklandacnz~paulRGraphicsrgraphicshtml
77
27 Deskriptive Statistik
Dieses Kapitel gibt einen kurzen Uumlberblick uumlber gaumlngige Verfahren der deskriptiven Statistik De-skriptive Statistik versucht im wesentlichen die Eigenschaften einer grossen Anzahl von Faumlllen inmoumlglichst charakteristische Kennwerte zusammenzufassen
Als Beispiel verwenden wir den Datensatz Bundesliga im Paket wikibooks1
library(wikibooks)data(Bundesliga)
2701 Uumlberblick uumlber den Datensatz
Wie class(Bundesliga) zeigt ist Bundesliga ein Objekt vom Typ dataframe2 Ein Uumlberblickuumlber die enthaltenen Variablen liefert
Rgt names(Bundesliga)[1] Saison Spieltag Datum[4] Anpfiff Heim Gast[7] ToreHeim ToreGast ToreHeimHalbzeit[10] ToreGastHalbzeit
Einen ersten Eindruck uumlber den ganzen dataframe liefert str3(Bundesliga) hinsichtlichder Variablentypen und summary4(Bundesliga) hinsichtlich deren typischen Auspraumlgungen
2702 Mittelwert Extremwerte und Streuung
Mittelwerte
Angenommen uns interessieren zunaumlchst die Tore pro Spiel (also der Tore der Heim- undGast-Mannschaft zusammen)
Rgt tore lt- Bundesliga$ToreHeim + Bundesliga$ToreGast
1 Kapitel 57 auf Seite 2432 httpdewikibooksorgwikiGNU20R3A20dataframe3 httpdewikibooksorgwikiGNU20R3A20str4 httpdewikibooksorgwikiGNU20R3A20summary
79
Deskriptive Statistik
Das arithmetische Mittel x = sumni=1 xin (durchschnittliche Anzahl an Toren pro Begegnung) errechnet
sich dann als
Rgt mean5(tore)[1] 30991
Den Zentralwert (Median) als ebenfalls gebraumluchlicher Mittelwert kann auch fuumlr ordinale Datenberechnet werden und liefert den Wert der die 50 kleineren von den 50 groumlsseren Variablenwertetrennt
Rgt median6(tore)[1] 3
Die Methode des Median laumlsst sich durch Quantile beliebig verallgemeinern
Rgt quantile(torec(0051))0 50 1000 3 12
Rgt quantile(toreseq(01by=01))10 20 30 40 50 60 70 80 90 1001 2 2 2 3 3 4 5 6 12
Was war die geringste (Minimum) und houmlchste Zahl (Maximum) an Toren in einem Spiel
Rgt cat7( min8(tore) max9(tore) )0 12
Minimum und Maximum liefert auch die Funktion range
Wie im Kapitel Umgang mit Datensaumltzen10 beschrieben koumlnnen wir uns die entsprechenden Faumlllejederzeit anzeigen lassen
Bundesliga[tore==max(tore)]
Streuung
Die Spannweite zwischen houmlchstem und niedrigstem Wert max(x)minusmin(x) erhaumllt man durch
diff11 ( range12 (tore ) )
Das gebraumluchlichste Maszlig fuumlr die Streuung einer Variablen ist die Varianz
var(x) = sumni=1 (ximinusx)2
n
10httpdewikibooksorgwikiGNU_R3A_Umgang_mit_DatensE4tzen_2528Erstellen252C_AuswE4hlen_und_Filtern2529
80
Weblinks
In Bezug auf unser Beispiel errechnet sich die Varianz entsprechend als
Rgt (sum( (tore-mean(tore) ) ˆ2) )(length(tore) )[1] 34091
Natuumlrlich verfuumlgt R uumlber diese Standardfunktion Allerdings berechnet die Funktion var13 dieinferenzstatistische davon abweichend definierte Variante der Varianz
varin f (x) =sum
ni=1 (ximinusx)2
nminus1 = var(x) middot nnminus1
Somit ermitteln wir die deskriptive Varianz am einfachsten mit
Rgt var(tore) (length(tore)-1) length(tore)[1] 34091
Das selbe Problem ergibt sich hinsichtlich der Standardabweichung die als Quadratwurzel dereben berechneten Varianz definiert ist Die Funktion sd14 liefert nur die inferenzstatistische Variante
Daher empfiehlt sich bei haumlufigem Gebrauch die Definition folgender Funktionen15
varianz lt- function(x) n=length(x) var(x) (n-1) nstdabw lt- function(x) n=length(x) sqrt(var(x) (n-1) n)
Damit kann die (deskriptive) Standardabweichung leichter berechnet werden
stdabw(tore)[1] 18464
2703 Haumlufigkeitstabellen und Prozenttabellen
Die Funktion table fasst verschiedene Kategorien zusammen und erstellt daraus eine Haumlufigkeits-tabelle
Rgt table(tore)tore
0 1 2 3 4 5 6 7 8 9 10 11 12880 1627 3057 2670 2438 1319 828 358 146 44 24 10 5
Die entsprechende Prozentwert-Tabelle erhaumllt man wenn man die Absolutwerte durch dieGesamtzahl der Begegnungen n (=Laumlnge des Vektors Tore) teilt und mit 100 multipliziert DerUumlbersichtlichkeit halber runden wir mit round16 noch auf 2 Nachkommastelle
13 httpdewikibooksorgwikiGNU20R3A20var14 httpdewikibooksorgwikiGNU20R3A20sd15 Kapitel 42 auf Seite 14916 httpdewikibooksorgwikiGNU20R3A20round
81
Deskriptive Statistik
Rgt round( table(tore) length(tore) 100 2)tore
0 1 2 3 4 5 6 7 8 9 1011 12656 1214 2280 1992 1819 984 618 267 109 033 018007 004
Eine schoumlne Formatierungsalternative stellt auch die Funktion describe17 zur verfuumlgung wenndas Paket Hmisc installiert wurde
Rgt describe18(tore)tore
n missing unique Mean 05 10 25 5075 90 95
13406 0 13 3099 0 1 2 34 6 6
0 1 2 3 4 5 6 7 8 9 10 11 12Frequency 880 1627 3057 2670 2438 1319 828 358 146 44 24 10 5 7 12 23 20 18 10 6 3 1 0 0 0 0
2704 Mehrdimensionale Haumlufigkeitsverteilungen
Die Funktion table19(ZeilenvariableSpaltenvariableweitere Dimensionen) erstellt auch konditionaleHaumlufigkeitstabellen Damit lassen sich zum Beispiel die Tore in Abhaumlngigkeit von der Saisondarstellen Eine andere Moumlglichkeit ist ftable die auch die Formelnotation
(abhaumlngige Var ˜ 1 unabhaumlng + 2 unabhaumlng + )
akzeptiert
ftable(tore˜Saisondata=Bundesliga)tore 0 1 2 3 4 5 6 7 8 9 10 11 12
Saison19631964 13 19 45 46 49 30 20 10 4 1 1 1 119641965 12 26 46 56 42 29 18 4 3 3 1 0 019651966 21 39 65 59 43 41 19 12 1 3 2 1 0[]
271 Gruppenspezifische Auswertung von Variablen
Angenommen uns interessiert fuumlr Datesatz bsp4 der mittlere Wert des Einkommens abhaumlngig vomGeschlecht Mit der Funktion tapply(VARIABLE GRUPPENVARIABLE FUNKTION)20
ist dies besonders einfach zu berechnen
17 httpdewikibooksorgwikiGNU20R3A20describe19 httpdewikibooksorgwikiGNU20R3A20table20 httpdewikibooksorgwikiGNU20R3A20tapply
82
Gruppenspezifische Auswertung von Variablen
gt tapply(bsp4$Einkommenbsp4$Geschlechtmean)
Dabei ist das erste Argument die betrachtete Variable und das zweite Argument eine Variable die dieGruppenzugehoumlrigkeit bezeichnet (in unserem Fall das Geschlecht) Als 3 Argument kann einebeliebige Funktion bestimmt werden Das ist im Falle der Funktion mean ein benannter Vektor
intersexuell maennlich weiblich
240000 116650 189975
83
28 Regressionsanalyse
281 Einleitung
Mit Regressionen wird versucht eine abhaumlngige metrische Variable in Abhaumlngigkeit von einer odermehreren unabhaumlngigen Variablen zu beschreiben Die abhaumlngige Variable soll dadurch uumlblicherweisekausal auf die Effekte andere Variablen zuruumlckgefuumlhrt werden (Bspw Regression der persoumlnlichenLaune abhaumlngig vom Wetter) Es gibt zum Teil recht unterschiedliche Regressionsverfahren und Rstellt eine Vielzahl an Methoden bereit Die einfachste Variante eines Regressionsmodells ist dielineare Regression
282 Lineare Regression
2821 Ein erstes Beispiel Lebensalter und Gewicht
Als erstes Beispiel verwenden wir den Datensatz aus Beispiel 51 welcher das Gewicht eines Babysan verschiedenen Lebenstagen enthaumllt Zunaumlchst stellen wir die Daten mit plot()2 graphisch dar
plot3(bsp5 type=o main=Gewicht des Babys ylab=Gewicht in Grammxlab=Lebenstag col=blue lwd=2)
Nun fuumlgen wir die Regressionsgeraden hinzu indem wir die Funktion lm(Y˜X)4 mit dem Befehlabline()5 in die Graphik integrieren
bull Y ist in diesem Falle die Spalte des Gewichts (also hier bsp5[2])bull X ist in diesem Falle die Spalte der Lebenstage (also hier bsp5[1])
Der Befehl lautet demzufolge
abline6(lm7(bsp5[2]˜bsp5[1]))
1 Kapitel 485 auf Seite 1732 httpdewikibooksorgwikiGNU20R3A20plot4 httpdewikibooksorgwikiGNU20R3A20lm5 httpdewikibooksorgwikiGNU20R3A20abline
85
Regressionsanalyse
Abb 3
Alternative mit xyplot
Um eine Regressionsgerade durch eine Punktwolke zu ziehen kann auch der Befehl xyplot ausdem Zusatzpaket lattice verwendet werden Falls lattice noch nicht installiert ist muss diesnatuumlrlich nun nachgeholt werden
installpackages8(lattice dependencies = T)
Anschlieszligend aktivieren wir das lattice-Paket
library9(lattice)
86
Lineare Regression
Eine Regressionsgerade erhaumllt man durch
xyplot10(y˜x type=c11(pr))
Angewendet auf Beispiel 512 lautet der Befehl
xyplot13(bsp5[2]˜bsp5[1] type=c14(pr))
Wir erhalten nun eine Punktwolke (type=p) der Daten durch welche die Regressionsgerade(type=r) verlaumluft
2822 Lineare Modelle mit R
Bei linearer Modellierung wird angenommen dass die Effekte verschiedener unabhaumlngiger Variablenfolgendermassen aufaddiert werden koumlnnen Y = b0 +b1 middotX1 +b2 middotX2 + +bn middotXn
In R koumlnnen zur Berechnug linearer Modelle zum Beispiel die Funktionen lm15 (fuumlr linear model)oder glm16 (fuumlr generalized linear model) genutzt werden Diese verwenden fuumlr den obigenAusdruck die folgende Formelnotation
Y ˜ Variable_X1 + Variable_X2 +
Die Funktion lm berechnet eine Reihe von Statistiken fuumlr dieses Modell die allerdings in der fuumlrdiese Funktion voreingestellten Ausgabemethode17 printlm unterdruumlckt werden Ausgegebenwerden standardmaumlssig nur die Aufrufbedingungen (Call) und die Koeffizienten
Rgt lm(bsp5$Gewicht˜bsp5$Lebenstag)
Calllm(formula = bsp5$Gewicht ˜ bsp5$Lebenstag)
Coefficients(Intercept) bsp5$Lebenstag
29711 375
Eine sehr viel detailliertere Auswertung bekommt man zum Beispiel durch Verwendung der Funktionsummary18
Rgt summary19 ( lm20 (bsp5$Gewicht ˜ bsp5$Lebenstag) )
Calllm(formula = bsp5$Gewicht ˜ bsp5$Lebenstag)
12 Kapitel 485 auf Seite 17315 httpdewikibooksorgwikiGNU20R3A20lm16 httpdewikibooksorgwikiGNU20R3A20glm17 httpdewikibooksorgwikiGNU20R3A20print18 httpdewikibooksorgwikiGNU20R3A20summary
87
Regressionsanalyse
Residuals
Min 1Q Median 3Q Max-1670 -903 204 797 1714
CoefficientsEstimate Std Error t value Pr(gt|t|)
(Intercept) 297113 4369 680 lt 2e-16 bsp5$Lebenstag 3748 119 315 21e-14
---Signif codes 0 lsquorsquo 0001 lsquorsquo 001 lsquorsquo 005 lsquorsquo 01 lsquo rsquo 1
Residual standard error 104 on 14 degrees of freedomMultiple R-Squared 0986 Adjusted R-squared 0985F-statistic 991 on 1 and 14 DF p-value 215e-14
Residuals
bull Hier sind die Quartile der Residuen angegeben
Coefficients
bull In der ersten Spalte werden die Konstante (Intercept) und die Regressionskoeffizienten desModells ausgegeben (Vorsicht beim Vergleich Dabei handelt es sich nicht um Beta-Werte)
In den folgenden Spalte werden (fuumlr die Beispieldaten selbstverstaumlndlich sinnlose) inferenzstatistischeMasse (Masse fuumlr die Verallgemeinerbarkeit der Stichprobe auf die Grundgesamtheit) angezeigt
bull Fuumlr jeden der i Koeffizienten wird neben der Berechnung Standardfehler (Std Error) eint-Test mit der Null-Hypothese H0 bi = 0 durchgefuumlhrt fuumlr den der entsprechende t-Wert und dieSignifikanz Pr(gt|t|) angegeben wird
Groumlssen die das Gesamtmodell betreffen
bull Der Standardfehler der Gesamtschaumltzung (Residual standard error)bull Das Bestimmtheitsmass R2 (Multiple R-Square) und das um die Anzahl der Modellvariablen
Korrigierte Bestimmtheitsmass R2korr (Adjusted R-squared) geben an wieviel Prozent der
Varianz der Residuen von den realen Werten durch das Modell erklaumlrt wird (in welchem Umfangalso die Schaumltzung von Y von den realen Werten abweicht) Bei einem Wert von 1 liegen allePunkte auf der Gerade Flaumlche Je naumlher an 0 sich der Wert annaumlhert umso mehr streuen dieMesswerte um den angenommenen Verlauf
bull Die Ergebnisse des F-Test in der letzten Zeile pruumlfen die Verallgemeinerbarkeit des Gesamtmodells(F-Wert Freiheitsgrade und Signifikanz)
88
29 Clusteranalyse
Clusteranalyse-Algorithmen finden sich in verschiedenen Paketen von R Eine Uumlbersicht findet sichin der Taskview Cluster1
bull k-Means Algorithmen (Standardpaket stats)
kmeans(x centers itermax = 10 nstart = 1 algorithm =c(Hartigan-Wong Lloyd Forgy MacQueen))
bull Fuzzy C-Means Algorithmen (Paket e1071)
cmeans(x centers itermax = 100 verbose = FALSE dist =euclidean method = cmeans m = 2 ratepar = NULL weights = 1control = list())
bull Hierarchische Clusteranalyse (Standardpaket stats)
hclust(d method = complete members=NULL)
bull Zur Berechnung der Distanzen d (Standardpaket stats)
dist(x method = euclidean diag = FALSE upper = FALSE p = 2)
1 httpcranr-projectorgwebviewsClusterhtml
89
30 Signifikanztests
Mit R lassen sich diverse Signifikanztests durchfuumlhren
301 Testauswahl
Bei der Auswahl des geeigneten Verfahrens ist von entscheidener Bedeutung
1 das Datenniveau (nominal-ordinal-metrisch)2 ob die Daten normalverteilt sind3 die Stichprobe (verbundenunverbunden)
91
Signifikanztests
NO
MIN
AL
OR
DIN
AL
ME
TR
ISC
Hni
chtn
orm
alve
rtei
ltab
eraumlh
nlic
hno
rmal
vert
eilt
unab
haumln-
gig
abhauml
ngig
unab
haumln-
gig
abhauml
ngig
unab
haumln-
gig
abhauml
ngig
unab
haumlng
igab
haumlng
ig
χχχ2 fuumlr
kx
l-F
elde
r2
x2
Feld
er
χχχ2 McN
emar
-Te
stfuuml
r2
x2
Feld
er
Man
n-W
hitn
eyW
ilcox
onM
ann-
Whi
tney
Wilc
oxon
F-Te
st(V
aria
nzqu
otie
nten
test
)en
tsch
eide
tuumlbe
r
t-Te
stfuuml
rve
rbun
dene
Stic
hpro
ben
Var
ianz
-ho
mog
enitauml
tt-
Test
Var
ianz
-he
tero
geni
taumlt
Wel
ch-
Test
nich
tpar
amet
risc
heTe
stve
rfah
ren
para
met
risc
heTe
stve
rfah
ren
92
Weblinks
302 Testdurchfuumlhrung in R
Test Durchfuumlhrung in RChi-Quadrat-Test (χ2) chisqtest1
Fisher-Exact-Test fishertest2
Kolmogoroff-Smirnov-Test kstest3
Mann-Whitney-Test wilcoxtest4 mit spezieller Optionseinstellungwilcox_test5 aus dem coin-Package
Shapiro-Wilk-Test shapirotest6
t-Test ttest7
Varianzquotienten-Test(alias F-Test)
vartest8
Welch-Test ttest9 mit spezieller OptionseinstellungWilcoxon-Test wilcoxtest10
303 Weblinks
bull Signifikanztests bei Wikipedia11
1 httpdewikibooksorgwikiGNU20R3A20chisqtest2 httpdewikibooksorgwikiGNU_R3A_fishertest3 httpdewikibooksorgwikiGNU_R3A_kstest4 httpdewikibooksorgwikiGNU20R3A20wilcoxtest23Mann-Whitney-Test5 httpdewikibooksorgwikiGNU20R3A20wilcox_test6 httpdewikibooksorgwikiGNU_R3A_shapirotest7 httpdewikibooksorgwikiGNU_R3A_ttest8 httpdewikibooksorgwikiGNU20R3A20vartest9 httpdewikibooksorgwikiGNU_R3A_ttest23Zweistichprobe10 httpdewikibooksorgwikiGNU20R3A20wilcoxtest11 httpdewikipediaorgwikiSignifikanztest
93
31 Rasch-Modelle
Fuumlr R liegen Zusatzpakete bereit mit deren Hilfe diverse Rasch-Modelle1 analysiert werden koumlnnen
1 httpdewikipediaorgwikiRasch-Modell
95
32 Package eRm
Mit Hilfe des Package eRm (extended Rasch modeling) lassen sich folgende Analysen durchfuumlhren
bull das dichotome logistische Rasch-Modellbull das linear-logistische Test-Modellbull das Ratingskalen-Modellbull das partial-credit Modellbull das lineare Ratingskalen-Modellbull das lineare partial-credit Modell
321 Installation
Das Package wird installiert mit dem Befehl (Unter Linux ist gcc-fortran als Voraussetzung zuinstallieren)
installpackages1(eRm dependencies=TRUE)
Mit Eingabe des Befehls werden die benoumltigten Zusatzpakete gtools splines ROCRgplots gdata mitinstalliert (sofern sie bislang noch nicht installiert wurden)
Vor der Nutzung des Packages muss es erst aktiviert werden per
library2(eRm)
322 Das dichotome logistische Rasch-Modell
Der Befehl zur Analyse nach dem dichotomen logistischen Rasch-Modell lautet RM()
Als Untersuchungsobjekt fuumlr RM() wird eine Matrix benoumltigt welche dichotome Daten enthaumllt (0und 1) Die Reihen der Matrix entsprechen den Untersuchungsfaumlllen (n) und die Spalten entsprechenden Ergebnissen der Items
3221 RM()
An den RM()-Befehl koumlnnen folgende Parameter uumlbergeben werden
97
Package eRm
RM(X W se=TRUE sum0=TRUE etaStart)
bull X = die zu analysierernde Datenmatrixbull W = optionale Designmatrix zur Normierung auf ein bestimmtes Itemsbull se = Berechnung der Standardfehler (TRUE=ja FALSE=nein)bull sum0 = TRUE=Summennormierung FALSE=Itemnormierungbull etaStart = optionale Uumlbergabe von vermuteten Parameterschaumltzwerten
3222 Beispieldatensatz
Als Beispieldatensatz sollen die Ergebnisse des Minigolfwettbewerbs aus Beispiel 83 genommenwerden
bull 0 bedeutet dass das entsprechende Loch nicht mit einem Schlag getroffen wurdebull 1 bedeutet dass das entsprechende Loch mit einem Schlag getroffen wurde
Die Ergebnisse des Wettbewerbs lauten wie folgt
Loch1 Loch2 Loch3 Loch4 Loch5 Loch6 Loch7 Loch8 Loch9Loch10Hans 0 1 1 0 1 1 0 1 11Karola 1 0 1 1 1 0 1 1 10Matthias 1 1 1 0 1 1 1 1 00Stefan 0 0 1 1 0 1 1 0 01Sabine 1 1 1 1 1 1 1 0 00Irma 1 1 0 1 1 1 0 1 00Heike 1 0 1 0 1 1 0 0 01Ralf 1 1 1 0 1 1 0 0 00Rainer 1 1 0 1 1 0 0 1 01Simon 1 0 1 1 1 0 1 0 10
Andreas 1 1 1 0 1 0 0 0 00Elke 1 1 0 1 0 1 0 0 10Gabi 0 1 1 1 0 0 1 0 01David 1 1 0 1 0 0 0 0 00
Jonas 1 1 0 1 1 0 1 1 00Nicklas 1 1 1 1 0 1 0 0 10Sandra 0 1 0 0 1 0 1 1 01Mario 1 0 1 0 1 1 0 0 00
3 Kapitel 488 auf Seite 179
98
Das dichotome logistische Rasch-Modell
Guido 1 1 1 0 0 0 0 0 10Lisa 0 1 1 0 0 0 1 0 00Peter 1 0 1 0 1 0 0 0 10
Justus 1 1 1 0 0 0 1 0 01
Josef 1 0 1 0 0 0 0 0 00Brigitte 1 1 1 0 0 0 1 0 10Kevin 0 1 0 0 1 0 0 1 01Marcel 1 1 0 0 0 0 0 0 00Nadine 1 0 0 1 0 1 0 0 10
Alex 1 0 0 0 0 0 0 0 00Katharina 0 1 0 0 0 1 1 0 11Daniel 1 1 0 0 0 0 0 0 00
Jens 1 1 0 1 0 0 1 0 10Dieter 1 0 0 0 0 0 1 1 00Sebastian 1 0 1 0 1 0 0 0 11
Anne 0 0 0 0 1 0 1 0 01
Diese Tabelle wird wie folgt erzeugt
minigolf lt- structure(list(Loch1 = c(0 1 1 0 1 1 1 1 1 11 1 0 1 1 1 0 1 1 0 1 1 1 1 01 1 1 0 1 1 1 1 0) Loch2 = c(1 0 1 0 1 1 0 1 1 01 1 1 1 1 1 1 0 1 1 0 1 0 1 11 0 0 1 1 1 0 0 0) Loch3 = c(1 1 1 1 1 0 1 1 0 11 0 1 0 0 1 0 1 1 1 1 1 1 1 00 0 0 0 0 0 0 1 0) Loch4 = c(0 1 0 1 1 1 0 0 1 10 1 1 1 1 1 0 0 0 0 0 0 0 0 00 1 0 0 0 1 0 0 0) Loch5 = c(1 1 1 0 1 1 1 1 11 1 0 0 0 1 0 1 1 0 0 1 0 0 0 10 0 0 0 0 0 0 1 1) Loch6 = c(1 0 1 1 1 1 1 1 0 00 1 0 0 0 1 0 1 0 0 0 0 0 0 00 1 0 1 0 0 0 0 0 ) Loch7 = c(0 1 1 1 1 0 0 0 0 10 0 1 0 1 0 1 0 0 1 0 1 0 1 00 0 0 1 0 1 1 0 1) Loch8 = c(1 1 1 0 0 1 0 0 10 0 0 0 0 1 0 1 0 0 0 0 0 0 0 10 0 0 0 0 0 1 0 0) Loch9 = c(1 1 0 0 0 0 0 0 0 10 1 0 0 0 1 0 0 1 0 1 0 0 1 0 01 0 1 0 1 0 1 0 ) Loch10 = c(1 0 0 1 0 0 1 0 1 00 0 1 0 0 0 1 0 0 0 0 1 0 0 1 0 00 1 0 0 0 1 1)) Names = c(Loch1 Loch2 Loch3Loch4 Loch5 Loch6 Loch7 Loch8 Loch9Loch10 ) class = dataframe rownames = c(Hans KarolaMatthias Stefan Sabine Irma HeikeRalf Rainer Simon Andreas Elke Gabi DavidJonas Nicklas Sandra Mario GuidoLisa Peter Justus Josef Brigitte Kevin MarcelNadine Alex Katharina Daniel JensDieter Sebastian Anne))
99
Package eRm
3223 Parameterschaumltzung
Die Analyse und Parameterschaumltzung erfolgt zunaumlchst durch Aufruf der Funktion RM()
RM(minigolf)
Dies liefert folgende Ausgabe
Results of RM estimation
Call RM(X = minigolf)
Conditional log-likelihood -1557848Number of iterations 17Number of parameters 9
Basic Parameters etaeta 1 eta 2 eta 3 eta 4 eta 5
eta 6 eta 7 eta 8 eta 9Estimate 07802107 04036248 -03177005 01641012 -04439830-007408871 -08568075 -04439830 -05748605StdErr 03448683 03320590 03359948 03291390 03407310033035472 03653347 03407311 03469895
Diese Ausgabe zeigt lediglich die eta-Parameter mit dazugehoumlriger Standardabweichung an Da zuweiteren Analysen der Output des RM(minigolf)-Befehls benoumltigt wird speichern wir diesen indie Variable result
result lt- RM(minigolf)
Einen besseren Uumlberblick uumlber die soeben durchgefuumlhrte Analyse bietet die summary()4-FunktionMit ihrem Aufruf werden auch die wichtigen beta-Parameter ausgegeben
summary5(result)
Dies liefert folgende Ausgabe
Results of RM estimation
Call RM(X = minigolf)
Conditional log-likelihood -1557848Number of iterations 17Number of parameters 9
Basic Parameters (eta) with 095 CIEstimate Std Error lower CI upper CI
eta 1 0780 0345 0104 1456eta 2 0404 0332 -0247 1054
4 httpdewikibooksorgwikiGNU20R3A20summary
100
Das dichotome logistische Rasch-Modell
eta 3 -0318 0336 -0976 0341eta 4 0164 0329 -0481 0809eta 5 -0444 0341 -1112 0224eta 6 -0074 0330 -0722 0573eta 7 -0857 0365 -1573 -0141eta 8 -0444 0341 -1112 0224eta 9 -0575 0347 -1255 0105
Item Easiness Parameters (beta) with 095 CIEstimate Std Error lower CI upper CI
beta Loch1 1363 0385 0609 2118beta Loch2 0780 0345 0104 1456beta Loch3 0404 0332 -0247 1054beta Loch4 -0318 0336 -0976 0341beta Loch5 0164 0329 -0481 0809beta Loch6 -0444 0341 -1112 0224beta Loch7 -0074 0330 -0722 0573beta Loch8 -0857 0365 -1573 -0141beta Loch9 -0444 0341 -1112 0224beta Loch10 -0575 0347 -1255 0105
Zur graphischen Darstellung stehen die Funktionen plotICC() und plotjointICC() zur Ver-fuumlgung plotjointICC() benoumltigt das RM()-Output und zeigt die Item-Characteristic-Curvesaller Variablen an
plotjointICC(RM(minigolf))
oder in unserem Fall
plotjointICC(result)
101
Package eRm
Abb 4
Mit plotICC() werden die Item-Characteristic-Curve fuumlr jedes Item einzeln graphisch dargestelltHierbei wird durch druumlcken der Returntaste zur naumlchsten Item-Graphik gewechselt
plotICC(result)
Im Gegensatz zu plotjointICC() kann plotICC() auch die Outputs von PCM()6 undRSM()7 verarbeiten
6 Kapitel 325 auf Seite 1207 Kapitel 324 auf Seite 113
102
Das dichotome logistische Rasch-Modell
Schaumltzung der Personenparameter
Die Schaumltzung der Personenparameter erfolgt mit dem Befehl personparameter() Als Inputbenoumltigt der Befehl den Output der RM()-Analyse
personparameter(RM(minigolf))
oder in unserem Fall auch
personparameter(result)
Dies liefert die Ausgabe
Person Parameters
Raw Score Estimate StdError0 -330890751 NA1 -237460583 108141932 -150799727 082335093 -091866630 072387224 -043133018 067818615 001539553 066283186 045847521 067279297 093481125 071365958 141970665 NA9 190460205 NA10 238949746 NA
Auch hier ist es sinnvoll den Output in eine Variable zu speichern
pp lt- personparameter(result)
Die Ausgabe laumlsst sich mit der plot()8-Funktion grafisch darstellen
plot(pp)
8 httpdewikibooksorgwikiGNU20R3A20plot
103
Package eRm
Abb 5
Ruft man den summary()9-Befehl auf erhaumllt man die Personenparameter fuumlr jeden einzelnenProbanden
summary(pp)
Estimation of Ability Parameters
Collapsed log-likelihood -3738117Number of iterations 9Number of parameters 7
9 httpdewikibooksorgwikiGNU20R3A20summary
104
Das dichotome logistische Rasch-Modell
ML estimated ability parameters (without spline interpolatedvalues)
Estimate Std Err 25 975 theta Hans 093481125 07136595 -04639356 23335581theta Karola 093481125 07136595 -04639356 23335581theta Matthias 093481125 07136595 -04639356 23335581theta Stefan 001539553 06628318 -12837309 13145219theta Sabine 093481125 07136595 -04639356 23335581theta Irma 045847521 06727929 -08601747 17771251theta Heike 001539553 06628318 -12837309 13145219theta Ralf 001539553 06628318 -12837309 13145219theta Rainer 045847521 06727929 -08601747 17771251theta Simon 045847521 06727929 -08601747 17771251theta Andreas -043133018 06781861 -17605505 08978901theta Elke 001539553 06628318 -12837309 13145219theta Gabi 001539553 06628318 -12837309 13145219theta David -091866630 07238722 -23374298 05000972theta Jonas 045847521 06727929 -08601747 17771251theta Nicklas 045847521 06727929 -08601747 17771251theta Sandra 001539553 06628318 -12837309 13145219theta Mario -043133018 06781861 -17605505 08978901theta Guido -043133018 06781861 -17605505 08978901theta Lisa -091866630 07238722 -23374298 05000972theta Peter -043133018 06781861 -17605505 08978901theta Justus 001539553 06628318 -12837309 13145219theta Josef -150799727 08233509 -31217353 01057408theta Brigitte 001539553 06628318 -12837309 13145219theta Kevin -043133018 06781861 -17605505 08978901theta Marcel -150799727 08233509 -31217353 01057408theta Nadine -043133018 06781861 -17605505 08978901theta Alex -237460583 10814193 -44941487 -02550629theta Katharina 001539553 06628318 -12837309 13145219theta Daniel -150799727 08233509 -31217353 01057408theta Jens 001539553 06628318 -12837309 13145219theta Dieter -091866630 07238722 -23374298 05000972theta Sebastian 001539553 06628318 -12837309 13145219theta Anne -091866630 07238722 -23374298 05000972
3224 Guumlltigkeitskontrollen
Das aufgestellte Rasch-Modell laumlsst sich auf verschiedene Weisen hinsichtlich seiner Guumlltigkeituumlberpruumlfen
bull bedingter Likelihood-Quotiententest
bedingter Likelihood-Quotiententest
Der bedingte Likelihood-Quotiententest erfolgt durch Aufruf der Funktion LRtest
LRtest(object splitcr = median se = FALSE)
Hierbei gelten die Parameter
bull object = Output von RM() PCM() oder RSM()bull splitcr = Teilungskriterium median mean oder in Form eines Vektorsbull se = Berechnung der Standardfehler (TRUE=ja FALSE=nein)
105
Package eRm
Es gelten folgende Hypothesen
bull H0 = Das Rasch-Modell gilt (keine Signifikanz)bull H1 = Das Rasch-Modell gilt nicht (Signifikanz)
Wir rufen nun die Funktion fuumlr unseren Minigolfwettbewerb auf
LRtest(result)
und erhalten die Ausgabe
Warning message Persons with median raw scores are assigned to thelower raw score group
Andersen LR-testLR-value 1258Chi-square df 9p-value 0183
Hierbei ist LR-value der Chi2-Wert und df die Anzahl der Freiheitsgrade Da der p-Wert nichtsignifikant ist wird H0 = Das Rasch-Modell gilt beibehalten Der kritische Chi2-Wert kann nochmanuell per qchisq()10 errechnet werden Hierbei muumlssen Testwahrscheinlichkeit und Anzahl derFreiheitsgrade uumlbergeben werden
qchisq11(095df=21)
Dies liefert das Ergebnis
[1] 3267057
Da der Chi2-Wert des Tests kleiner ist als der kritische Wert bestaumltigt sich erneut die Annahme dassH0 = Das Rasch-Modell gilt beibehalten werden kann
Wald-Test
Der Wald-Test erfolgt durch Aufruf der Funktion Waldtest
Waldtest(object splitcr = median)
Hierbei gelten die Parameter
bull object = Output von RM()bull splitcr = Teilungskriterium median mean oder in Form eines Vektors
10 httpdewikibooksorgwikiGNU20R3A20qchisq
106
Das dichotome logistische Rasch-Modell
Erreicht ein Item Signifikanz kann es nicht weiterverwendet werden Rufen wir die Funktion auf
Waldtest(result)
erhalten wir die Ausgabe
Wald test on item level (z-values)
z-statistic p-valuebeta Loch1 0127 0899beta Loch2 0462 0644beta Loch3 0764 0445beta Loch4 -1317 0188beta Loch5 -1299 0194beta Loch6 0009 0993beta Loch7 0721 0471beta Loch8 -1661 0097beta Loch9 0795 0427beta Loch10 2041 0041
Wir sehen dass fuumlr Loch10 ein signifikanter p-Wert errechnet wurde Somit kann dieses Item nichtweiter verwendet werden
Graphischer Test
Zur graphischen Uumlberpruumlfung steht die Funktion plotGOF() zur Verfuumlgung Sie benoumltigt denOutput der Funktion LRtest()
plotGOF(LRtest(result))
Wir erhalten die folgende Graphik
107
Package eRm
Abb 6
Itemfit Personfit und theoretische Wahrscheinlichkeiten
eRm stellt weitere Funktionen zur Uumlberpruumlfung des Modells zur Verfuumlgung Mit itemfit() lassensich Item- mit personfit() Personenparameter uumlberpruumlfen
itemfit(pp)
liefert die Ausgabe
108
Das dichotome logistische Rasch-Modell
Itemfit StatisticsChisq df p-value Outfit MSQ Infit MSQ
Loch1 43838 34 0120 1289 1230Loch2 36199 34 0366 1065 1055Loch3 33027 34 0515 0971 0997Loch4 29060 34 0708 0855 0901Loch5 28248 34 0745 0831 0880Loch6 28045 34 0754 0825 0902Loch7 33386 34 0498 0982 1010Loch8 28035 34 0754 0825 0860Loch9 31049 34 0613 0913 0994Loch10 34331 34 0452 1010 1082
und
personfit(pp)
liefert die Ausgabe
Personfit StatisticsChisq df p-value Outfit MSQ Infit MSQ
Hans 17798 10 0058 1780 1303Karola 11819 10 0297 1182 1095Matthias 7756 10 0653 0776 0893Stefan 14821 10 0139 1482 1397Sabine 6598 10 0763 0660 0761Irma 10073 10 0434 1007 1057Heike 10010 10 0440 1001 1017Ralf 7068 10 0719 0707 0731Rainer 10336 10 0412 1034 1087Simon 9683 10 0469 0968 0948Andreas 5985 10 0817 0598 0628Elke 9789 10 0459 0979 1019Gabi 12173 10 0274 1217 1138David 7577 10 0670 0758 0782Jonas 9314 10 0503 0931 0975Nicklas 8608 10 0570 0861 0918Sandra 13950 10 0175 1395 1299Mario 8679 10 0563 0868 0897Guido 7427 10 0685 0743 0756Lisa 8748 10 0556 0875 0981Peter 8679 10 0563 0868 0897Justus 7841 10 0644 0784 0810Josef 5786 10 0833 0579 0745Brigitte 7546 10 0673 0755 0783Kevin 13795 10 0183 1380 1296Marcel 4687 10 0911 0469 0641Nadine 11708 10 0305 1171 1183Alex 3566 10 0965 0357 0715Katharina 14189 10 0165 1419 1349Daniel 4687 10 0911 0469 0641Jens 9023 10 0530 0902 0940Dieter 12208 10 0271 1221 1070Sebastian 10010 10 0440 1001 1017Anne 13278 10 0209 1328 1333
Die Funktion pmat() liefert die Item-Personen-Matrix zuruumlck welche die theoretisch zuerwartenden Wahrscheinlichkeiten enthaumllt
109
Package eRm
pmat(pp)
Loch1 Loch2 Loch3 Loch4 Loch5Loch6 Loch7 Loch8 Loch9 Loch10Hans 09087360 08474865 07922326 064956115 07500562806203015 070281159 051949106 06203015 058902851Karola 09087360 08474865 07922326 064956115 07500562806203015 070281159 051949106 06203015 058902851Matthias 09087360 08474865 07922326 064956115 07500562806203015 070281159 051949106 06203015 058902851Stefan 07988114 06890338 06032488 042499412 05447541003944637 048533092 030123749 03944637 036367126Sabine 09087360 08474865 07922326 064956115 07500562806203015 070281159 051949106 06203015 058902851Irma 08608014 07753352 07030992 053513568 06508042905036230 059493064 040171309 05036230 047093647Heike 07988114 06890338 06032488 042499412 05447541003944637 048533092 030123749 03944637 036367126Ralf 07988114 06890338 06032488 042499412 05447541003944637 048533092 030123749 03944637 036367126Rainer 08608014 07753352 07030992 053513568 06508042905036230 059493064 040171309 05036230 047093647Simon 08608014 07753352 07030992 053513568 06508042905036230 059493064 040171309 05036230 047093647Andreas 07175126 05863461 04930741 032103255 04335875102941499 037626806 021616820 02941499 026772600Elke 07988114 06890338 06032488 042499412 05447541003944637 048533092 030123749 03944637 036367126Gabi 07988114 06890338 06032488 042499412 05447541003944637 048533092 030123749 03944637 036367126David 06094070 04654413 03740124 022506903 03198274102038101 027036825 014486293 02038101 018339296Jonas 08608014 07753352 07030992 053513568 06508042905036230 059493064 040171309 05036230 047093647Nicklas 08608014 07753352 07030992 053513568 06508042905036230 059493064 040171309 05036230 047093647Sandra 07988114 06890338 06032488 042499412 05447541003944637 048533092 030123749 03944637 036367126Mario 07175126 05863461 04930741 032103255 04335875102941499 037626806 021616820 02941499 026772600Guido 07175126 05863461 04930741 032103255 04335875102941499 037626806 021616820 02941499 026772600Lisa 06094070 04654413 03740124 022506903 03198274102038101 027036825 014486293 02038101 018339296Peter 07175126 05863461 04930741 032103255 04335875102941499 037626806 021616820 02941499 026772600Justus 07988114 06890338 06032488 042499412 05447541003944637 048533092 030123749 03944637 036367126Josef 04639351 03256806 02489215 013875159 02068700901243376 017050026 008589618 01243376 011077415Brigitte 07988114 06890338 06032488 042499412 05447541003944637 048533092 030123749 03944637 036367126Kevin 07175126 05863461 04930741 032103255 04335875102941499 037626806 021616820 02941499 026772600Marcel 04639351 03256806 02489215 013875159 02068700901243376 017050026 008589618 01243376 011077415Nadine 07175126 05863461 04930741 032103255 04335875102941499 037626806 021616820 02941499 026772600Alex 02667609 01687664 01222835 006342887 00988111300563279 007953407 003800055 00563279 004976174Katharina 07988114 06890338 06032488 042499412 05447541003944637 048533092 030123749 03944637 036367126Daniel 04639351 03256806 02489215 013875159 02068700901243376 017050026 008589618 01243376 011077415
110
Das dichotome logistische Rasch-Modell
Jens 07988114 06890338 06032488 042499412 05447541003944637 048533092 030123749 03944637 036367126Dieter 06094070 04654413 03740124 022506903 03198274102038101 027036825 014486293 02038101 018339296Sebastian 07988114 06890338 06032488 042499412 05447541003944637 048533092 030123749 03944637 036367126Anne 06094070 04654413 03740124 022506903 03198274102038101 027036825 014486293 02038101 018339296
Die Funktion residuals()12 gibt schlieszliglich die Residuen aus
Loch1 Loch2 Loch3 Loch4 Loch5Loch6 Loch7 Loch8 Loch9 Loch10Hans -31555061 04242166 05121089 -13614569 0577263607823805 -15378130 09617489 07823805 08352908Karola 03169064 -23572861 05121089 07345073 05772636-12781505 06502741 09617489 07823805 -11971879Matthias 03169064 04242166 05121089 -13614569 0577263607823805 06502741 09617489 -12781505 -11971879Stefan -19926014 -14885510 08109814 11631740 -1093899012389866 10297814 -06565831 -08071113 13227759Sabine 03169064 04242166 05121089 07345073 0577263607823805 06502741 -10397724 -12781505 -11971879Irma 04021296 05382980 -15388725 09320327 0732502709927801 -12119047 12203847 -10072724 -09434682Heike 05018565 -14885510 08109814 -08597166 0914161212389866 -09710798 -06565831 -08071113 13227759Ralf 05018565 06717943 08109814 -08597166 0914161212389866 -09710798 -06565831 -08071113 -07559859Rainer 04021296 05382980 -15388725 09320327 07325027-10072724 -12119047 12203847 -10072724 10599192Simon 04021296 -18577071 06498264 09320327 07325027-10072724 08251474 -08194137 09927801 -09434682Andreas 06274582 08399270 10139491 -06876225 11429521-06455474 -07766935 -05251513 -06455474 -06046561Elke 05018565 06717943 -12330739 11631740 -1093899012389866 -09710798 -06565831 12389866 -07559859Gabi -19926014 06717943 08109814 11631740 -10938990-08071113 10297814 -06565831 -08071113 13227759David 08005870 10716803 -07729656 18555542 -06857223-05059463 -06087318 -04115862 -05059463 -04738979Jonas 04021296 05382980 -15388725 09320327 07325027-10072724 08251474 12203847 -10072724 -09434682Nicklas 04021296 05382980 06498264 09320327 -1365182609927801 -12119047 -08194137 09927801 -09434682Sandra -19926014 06717943 -12330739 -08597166 09141612-08071113 10297814 15230364 -08071113 13227759Mario 06274582 -11905796 10139491 -06876225 1142952115490729 -07766935 -05251513 -06455474 -06046561Guido 06274582 08399270 10139491 -06876225 -08749273-06455474 -07766935 -05251513 15490729 -06046561Lisa -12490835 10716803 12937187 -05389226 -06857223-05059463 16427596 -04115862 -05059463 -04738979Peter 06274582 -11905796 10139491 -06876225 11429521-06455474 -07766935 -05251513 15490729 -06046561Justus 05018565 06717943 08109814 -08597166 -10938990-08071113 10297814 -06565831 -08071113 13227759Josef 10749298 -06949654 17370465 -04013791 -05107127-03768191 -04533717 -03065414 -03768191 -03529500Brigitte 05018565 06717943 08109814 -08597166 -10938990
12 httpdewikibooksorgwikiGNU20R3A20residuals
111
Package eRm
-08071113 10297814 -06565831 12389866 -07559859Kevin -15937316 08399270 -09862428 -06876225 11429521-06455474 -07766935 19042131 -06455474 16538325Marcel 10749298 14389206 -05756898 -04013791 -05107127-03768191 -04533717 -03065414 -03768191 -03529500Nadine 06274582 -11905796 -09862428 14542864 -0874927315490729 -07766935 -05251513 15490729 -06046561Alex 16579131 -04505900 -03732561 -02602394 -03311273-02443156 -02939495 -01987502 -02443156 -02288398Katharina -19926014 06717943 -12330739 -08597166 -1093899012389866 10297814 -06565831 12389866 13227759Daniel 10749298 14389206 -05756898 -04013791 -05107127-03768191 -04533717 -03065414 -03768191 -03529500Jens 05018565 06717943 -12330739 11631740 -10938990-08071113 10297814 -06565831 12389866 -07559859Dieter 08005870 -09331141 -07729656 -05389226 -06857223-05059463 16427596 24296249 -05059463 -04738979Sebastian 05018565 -14885510 08109814 -08597166 09141612-08071113 -09710798 -06565831 12389866 13227759Anne -12490835 -09331141 -07729656 -05389226 14583163-05059463 16427596 -04115862 -05059463 21101592
Informationsindices
Die Informationsindices Akaike Information Criterion (AIC) Bayes Information Criterion (BIC)und consistent Akaike Information Criterion (CAIC) uumlberpruumlfen welches Modell am besten aufdie Daten passt Hierbei gilt je kleiner der Informationsindex desto besser passt das Modell Die da-zugehoumlrige Funktion lautet IC() und benoumltigt den Output der personparameter()-FunktionIn unserem Beispiel rufen wir sie also auf per
IC(personparameter(RM(minigolf)))
oder
IC(personparameter(result))
oder
IC(pp)
Die Funktion liefert die folgende Ausgabe
Information Criteriavalue npar AIC BIC cAIC
joint log-lik -1998864 16 4317728 4561946 4721946marginal log-lik -2161203 9 4502406 4639779 4729779conditional log-lik -1557848 9 3295697 3433069 3523069
112
Das linear-logistische Test-Modell
323 Das linear-logistische Test-Modell
Der Befehl zur Analyse nach dem linear-logistischen Test-Modell lautet LLTM()
Als Untersuchungsobjekt fuumlr LLTM() wird eine Matrix benoumltigt welche dichotome Daten enthaumllt (0und 1) Die Reihen der Matrix entsprechen den Untersuchungsfaumlllen (n) und die Spalten entsprechenden Ergebnissen der Items
3231 LLTM()
An den LLTM()-Befehl koumlnnen folgende Parameter uumlbergeben werden
LLTM(X W mpoints = 1 groupvec = 1 se = TRUE sum0 = TRUEetaStart)
bull X = die zu analysierernde Datenmatrixbull W = optionale Designmatrix zur Normierung auf ein bestimmtes Itemsbull mpoints = Anzahl der Messpunktebull groupvec = Vector der Laumlnge N welche die Gruppenzugehoumlrigkeiten enthaumllt Wirdgroupvec=1 gesetzt werden keine Gruppen verwendet
bull se = Berechnung der Standardfehler (TRUE=ja FALSE=nein)bull sum0 = TRUE=Normierung der Parameter auf sum-0 FALSE=Begrenzung des ersten Parameters
auf 0bull etaStart = optionale Uumlbergabe von vermuteten Parameterschaumltzwerten
324 Das Ratingskalen-Modell
Der Befehl zur Analyse nach dem Ratingskalen-Modell lautet RSM()
Als Untersuchungsobjekt fuumlr RSM() wird eine Matrix oder Datenframe benoumltigt Die Reihen derMatrix entsprechen den Untersuchungsfaumlllen (n) und die Spalten entsprechen den Ergebnissen derItems
3241 RSM()
Die folgenden Parameter koumlnnen an RSM() uumlbergeben werden
RSM(X W se = TRUE sum0 = TRUE etaStart)
bull X = die zu analysierernde Datenmatrixbull W = optionale Designmatrix zur Normierung auf ein bestimmtes Itemsbull se = Berechnung der Standardfehler (TRUE=ja FALSE=nein)bull sum0 = TRUE=Normierung der Parameter auf sum-0 FALSE=Begrenzung des ersten Parameters
auf 0
113
Package eRm
bull etaStart = optionale Uumlbergabe von vermuteten Parameterschaumltzwerten
3242 Beispieldatensatz
Als Beispieldatensatz nehmen wir die Fragebogenerhebung aus Beispiel 913 Dieser Fragebo-gen besteht aus 27 Fragen welche die Antworten nie selten manchmal oft immer zulassen Die Antworten werden wie folgt codiert
bull 1 = niebull 2 = seltenbull 3 = manchmalbull 4 = oftbull 5 = immer
Der Fragebogen wurde von 122 Personen ausgefuumlllt Der Befehl zur Erzeugung dieses Datensatzeslautet
bsp9 lt- structure(list(Frage1 = c(4 4 5 5 5 1 3 3 3 3 5 55 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 3 3 2 5 45 2 4 3 2 5 5 3 3 3 3 3 3 3 3 33 3 4 4 4 4 4 4 4 4 4 4 4 5 1 1 1 1 1 1 1 1 11 1 2 2 2 2 2 2 2 2 2 2 3 3 3 33 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5) Frage2 = c(3 5 45 4 5 3 3 5 3 5 4 4 4 2 5 5 3 22 2 2 3 2 3 5 4 4 3 3 5 3 5 2 3 3 5 4 3 4 1 44 4 5 2 2 3 2 3 5 5 3 5 3 3 5 43 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 51 1 1 1 1 1 1 1 1 1 1 2 2 2 2 22 2 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 55 5) Frage3 = c(4 4 4 4 3 3 2 2 4 2 53 1 2 3 4 4 3 3 3 4 5 4 5 4 4 3 3 5 5 2 4 43 2 3 4 3 3 3 1 3 3 2 4 1 1 3 3 3 55 4 2 5 4 4 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 44 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 55 5 5 5 5 5 5 5) Frage4 = c(4 3 1 3 3
4 4 3 3 3 5 5 1 3 2 2 4 4 2 2 4 5 4 5 3 4 5 55 3 5 2 5 3 2 3 3 4 3 4 1 2 3 4 52 3 2 3 2 4 5 4 1 4 2 4 2 3 3 3 3 3 3 3 3 3 33 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 33 3 3 3 5 5 5 5 5 5 5 5 5 5)Frage5 = c(5 1 2 5 2 4 4 1 1 4 5 4 3 5 3 5 1 1 45 5 4 2 4 3 1 2 1 3 4 2 1 1 4 1 12 4 2 3 3 4 4 4 5 2 2 2 3 3 4 2 3 3 4 3 5 2 33 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 22 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 55 5 5 5 5 5 5) Frage6 = c(5 3 1 4 5 5 4 3 3 4 5 5
4 4 3 2 4 5 3 3 3 3 3 4 3 4 5 4 25 5 4 5 4 2 2 5 3 3 3 1 4 4 4 5 3 2 3 1 2 5 43 5 4 3 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 12 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 33 3 3 5 5 5 5 5 5 5 5 5 5) Frage7 = c(3 3 2 4 4 34 3 5 3 4 5 3 4 2 3 4 3 4 3 2 2 2
1 4 4 4 4 3 3 5 5 4 4 4 2 5 3 3 4 2 5 3 3 5 4
13 Kapitel 489 auf Seite 181
114
Das Ratingskalen-Modell
3 5 3 3 4 5 4 3 5 4 4 5 3 3 3 3 33 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 1 1 1 1 11 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 33 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5) Frage8 =c(4 5 5 5 4 5 4 2 5 4 5 5 4 4 4 4 53 3 1 3 4 4 3 3 5 5 5 5 4 5 5 5 3 3 4 5 3 3 42 5 3 4 5 3 3 4 3 4 5 4 4 4 5 4 5
4 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 45 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 22 2 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 55 5) Frage9 = c(5 5 5 5 5 5 5 2 5 3 5 4
4 4 2 4 5 4 2 2 3 4 4 4 3 5 5 5 5 3 4 4 5 4 54 5 4 4 4 2 5 4 4 5 2 3 2 4 2 4 4 45 2 3 5 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 44 4 4 4 4 5 1 1 1 1 1 1 1 1 1 1 1 2 22 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) Frage10 = c(2 1 5 4 3 4 2 45 1 3 2 1 1 1 5 4 2 2 5 3 5 2 2 3 1 1 2 5 5 23 3 4 2 5 4 5 5 3 2 5 4 3 4 2 4 1 43 5 3 3 4 5 3 5 4 3 3 3 3 3 3 3 3 3 3 3 4 4 44 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 55 5 5 5 5 5 5 5 5) Frage11 = c(3 1 5 4
4 3 3 2 1 3 4 4 1 4 4 4 4 1 3 5 5 5 3 5 5 2 52 1 2 5 3 5 5 1 1 2 5 4 4 3 3 4 4 53 3 3 3 3 5 5 5 5 3 3 5 5 3 3 3 3 3 3 3 3 3 33 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 33 3 3 5 5 5 5 5 5 5 5 5 5) Frage12 = c(15 3 2 5 3 2 1 1 2 1 4 3 1 3 1 1 3 3 1 3 1 2 24 4 5 5 3 1 3 1 1 4 2 1 5 4 3 3 2 43 2 5 5 1 1 3 3 4 5 4 4 4 2 5 1 3 3 3 3 3 3 33 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 33 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5)Frage13 = c(2 4 2 3 3 3 3 3 2 2 4 4 1 2 1 2 4 4 23 2 3 3 1 2 3 5 4 4 2 1 3 5 3 4 1 53 3 3 1 2 3 1 4 5 3 1 4 4 2 4 2 2 5 2 3 5 3 33 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 22 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 55 5 5) Frage14 = c(4 3 2 4 4 5 4 3 2 4 5 4 5 3 14 5 5 1 3 2 3 3 5 3 3 5 4 4 3 5 3 5 3
4 3 4 4 4 2 1 4 3 3 4 2 2 5 4 4 1 2 2 3 4 3 35 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 22 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 55 5 5 5 5 5) Frage15 = c(4 3 2 5 4 5 3 2 1 4 5 45 3 3 3 5 5 2 3 4 4 1 2 3 4 5 5 3 5 12 3 3 1 4 5 3 5 2 2 5 4 4 4 5 5 4 3 3 1 5 1 15 2 3 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 22 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 55 5 5 5 5 5 5 5 5) Frage16 = c(3 5 1 5 4 1 3 2 32 5 5 5 4 4 3 4 4 4 4 4 4 3 4 4 4 5 3
1 2 5 4 3 3 5 4 4 4 5 4 4 3 4 3 4 5 5 5 4 4 55 1 5 5 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 12 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 33 3 5 5 5 5 5 5 5 5 5 5) Frage17 = c(4 4 4 2 3 22 4 5 3 1 4 5 3 2 4 4 4 1 2 4 5 3 4 14 5 3 1 3 3 4 1 5 2 4 3 5 5 4 1 5 3 4 4 5 45 4 4 5 5 3 4 5 4 5 5 3 3 3 3 3 3 3 33 3 3 4 4 4 4 4 4 4 4 4 4 4 5 1 1 1 1 1 1 11 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 33 3 3 3 3 5 5 5 5 5 5 5 5 5 5) Frage18 = c(4 2 15 3 5 2 4 3 4 2 3 1 3 2 2 2 1 1 4 1 52 5 2 1 2 5 3 2 5 4 4 1 3 1 2 5 4 5 3 5 3 3 5
115
Package eRm
3 5 2 4 5 1 2 1 3 5 2 3 4 3 3 3 3 33 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 1 1 1 1 11 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 33 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5) Frage19 =c(3 1 4 5 4 5 4 2 5 5 5 3 3 5 4 4 1 2 22 1 1 1 1 3 3 4 2 4 1 3 5 5 5 2 4 4 4 3 5 2 43 4 5 3 5 2 3 4 5 5 3 1 5 3 2 5 3 33 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 1 11 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 22 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5)Frage20 = c(4 3 4 3 3 5 4 1 4 3 5 4 4 2 4 25 4 4 1 3 3 2 5 4 5 5 5 5 4 5 4 5 4 2 4 5 2 43 2 4 3 3 5 5 2 3 1 2 2 4 5 5 5 3 35 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 45 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 22 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 55) Frage21 = c(4 2 3 5 3 5 4 3 3 3 5 5 55 4 5 5 3 5 3 3 2 3 4 3 5 5 5 5 5 5 4 4 4 4 44 2 4 3 2 5 3 4 5 3 2 4 4 4 3 5 5 5
4 4 3 5 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 44 4 4 5 1 1 1 1 1 1 1 1 1 1 1 2 2 22 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 55 5 5 5) Frage22 = c(5 3 5 4 3 5 4 1 5 35 4 4 4 3 5 5 3 4 4 3 3 2 3 5 5 5 5 5 4 2 2 55 3 4 4 4 4 3 5 3 3 4 5 5 3 3 5 5 55 3 5 4 4 4 5 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 44 4 4 4 4 4 5 1 1 1 1 1 1 1 1 1 1 12 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 55 5 5 5 5 5 5) Frage23 = c(4 5 4 2 2 4 3
1 5 4 5 4 4 5 5 5 5 4 5 3 2 3 2 4 4 4 4 4 5 45 3 3 4 3 3 1 4 4 3 3 4 4 5 5 4 4 2
4 5 5 5 3 5 5 5 4 4 3 3 3 3 3 3 3 3 3 3 3 4 44 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 35 5 5 5 5 5 5 5 5 5) Frage24 = c(5 4 1 4
4 5 4 3 5 4 4 5 4 4 3 1 4 4 3 2 3 2 2 5 4 5 34 3 5 5 4 4 3 1 5 4 3 2 3 3 4 3 3 3
4 1 4 3 4 5 3 2 5 2 5 4 4 3 3 3 3 3 3 3 3 3 33 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 33 3 3 5 5 5 5 5 5 5 5 5 5) Frage25 = c(33 1 3 4 5 4 3 4 3 4 4 4 5 3 3 4 5 4 1 3 2 31 4 4 5 5 5 4 1 4 2 4 5 4 5 4 2 4 3 43 4 4 5 1 5 2 3 5 5 3 5 3 5 4 4 3 3 3 3 3 33 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 33 3 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 52 2 2 4 5 4 4 3 5 5 5 5 5 3 5 3 5 53 3 3 2 3 3 4 4 5 2 5 3 4 5 4 3 3 4 4 4 5 3 33 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 22 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 55 5 5) Frage27 = c(2 5 2 4 4 4 3 1 3 5 5 5 5 4 34 2 2 3 3 2 2 3 4 3 5 5 4 5 3 1 3 1 22 4 5 4 4 3 5 4 3 4 5 5 3 5 3 4 5 4 3 5 4 4 55 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 22 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 55 5 5 5 5 5)) Names = c(Frage1 Frage2 Frage3Frage4 Frage5 Frage6 Frage7 Frage8 Frage9Frage10 Frage11 Frage12 Frage13 Frage14 Frage15Frage16 Frage17 Frage18 Frage19 Frage20Frage21 Frage22 Frage23 Frage24 Frage25 Frage26Frage27) rownames = c(NA 122L) class = dataframenaaction = structure(123231 Names = c(38 39 40 4142 43 44 45 46 47 48 49 50 5152 53 54 55 56 57 58 59 60 61 62
116
Das Ratingskalen-Modell
63 64 65 66 67 68 69 70 71 7273 74 75 76 77 78 79 80 81 82 158159 160 161 162 163 164 165 166167 168 169 170 171 172 173 174 175176 177 178 179 180 181 182 183 184185 186 187 188 189 190 191 192 193194 195 196 197 198 199 200 201202 203 204 205 206 207 208 209 210211 212 213 214 215 216 217 218 219220 221) class = omit))
Der Datensatz ist nun in der Variablen bsp9 gespeichert Die Daten koumlnnen eingesehen werdenindem die Variable aufgerufen wird
bsp9
3243 Parameterschaumltzung
Die Analyse erfolgt durch Aufruf der RSM()-Funktion
RSM(bsp9)
Da der Output noch fuumlr weitere Analysen benoumltigt wird speichern wir ihn in die Variablersmresult
rsmresult lt- RSM(bsp9)
Somit wird durch Aufruf der Variablen der Output wieder ausgegeben
rsmresult
Results of RSM estimation
Call RSM(X = bsp9)
Conditional log-likelihood -3045451Number of iterations 20Number of parameters 29
Basic Parameters etaeta 1 eta 2 eta 3 eta 4 eta 5
eta 6 eta 7 eta 8Estimate 003942847 -01626761 -01761274 -04188407 00664840003942847 03960766 03263914StdErr 011411907 01139070 01139206 01147358 01142076011411903 01164774 01158098
eta 9 eta 10 eta 11 eta 12 eta 13eta 14 eta 15 eta 16Estimate -02434006 -001457923 -05822437 -05003087 -00819464-008194639 02436041 003942844StdErr 01140388 011398516 01158746 01152457 01138975
117
Package eRm
011389774 01151493 011411904
eta 17 eta 18 eta 19 eta 20 eta 21 eta22 eta 23 eta 24 eta 25Estimate -03917694 -01357728 008002696 03263914 0368117502711103 001240908 00664840 03541815StdErr 01145923 01138901 011425720 01158098 0116197201153532 011404490 01142077 01160637
eta 26 eta 27 eta 28 eta 29Estimate 008002695 -12993059 -40572947 -75319724StdErr 011425714 01444744 02686848 04036785
Wird die Variable rsmresult an die summary()14-Funktion uumlbergeben werden neben deneta-Werten auch die beta-Werte angezeigt
summary(RSM(bsp9))
oder in unserem Fall
summary(rsmresult)
liefern die (hier in Wikibooks aus Platzgruumlnden gekuumlrzte) Ausgabe
Results of RSM estimation
Call RSM(X = bsp9)
Conditional log-likelihood -3045451Number of iterations 20Number of parameters 29
Basic Parameters (eta) with 095 CIEstimate Std Error lower CI upper CI
eta 1 0039 0114 -0184 0263eta 2 -0163 0114 -0386 0061eta 3 -0176 0114 -0399 0047eta 4 -0419 0115 -0644 -0194
( )
eta 27 -1299 0144 -1582 -1016eta 28 -4057 0269 -4584 -3531eta 29 -7532 0404 -8323 -6741
Item Easiness Parameters (beta) with 095 CIEstimate Std Error lower CI upper CI
beta Frage1c1 0080 0114 -0144 0304beta Frage1c2 -1139 0270 -1667 -0611beta Frage1c3 -3817 0433 -4666 -2968beta Frage1c4 -7212 0606 -8399 -6024beta Frage2c1 0039 0114 -0184 0263beta Frage2c2 -1220 0270 -1749 -0692
14 httpdewikibooksorgwikiGNU20R3A20summary
118
Das Ratingskalen-Modell
beta Frage2c3 -3939 0434 -4789 -3089beta Frage2c4 -7374 0607 -8564 -6185beta Frage3c1 -0163 0114 -0386 0061beta Frage3c2 -1625 0271 -2155 -1094beta Frage3c3 -4545 0438 -5403 -3687beta Frage3c4 -8183 0615 -9388 -6978
( )
beta Frage26c1 0354 0116 0127 0582beta Frage26c2 -0591 0271 -1122 -0060beta Frage26c3 -2995 0433 -3843 -2147beta Frage26c4 -6115 0601 -7294 -4937beta Frage27c1 0080 0114 -0144 0304beta Frage27c2 -1139 0270 -1667 -0611beta Frage27c3 -3817 0433 -4666 -2968beta Frage27c4 -7212 0606 -8399 -6024
Schwellenwerte
Die Schwellenwerte (Thresholds) der einzelnen Items werden mit der Funktion thresholds()angezeigt
thresholds(rsmresult)
liefert die Ausgabe
Design Matrix Block 1Location Threshold 1 Threshold 2 Threshold 3 Threshold 4
Frage1 180297 -008002 121928 267797 339466Frage2 184356 -003943 125988 271856 343525Frage3 204567 016268 146198 292066 363735Frage4 205912 017613 147543 293412 365081Frage5 230183 041884 171815 317683 389352Frage6 181651 -006648 123282 269150 340819Frage7 184356 -003943 125988 271856 343525Frage8 148692 -039608 090323 236191 307860Frage9 155660 -032639 097291 243160 314829Frage10 212639 024340 154271 300139 371808Frage11 189757 001458 131389 277257 348926Frage12 246524 058224 188155 334023 405692Frage13 238330 050031 179961 325830 397499Frage14 196494 008195 138125 283994 355662Frage15 196494 008195 138125 283994 355662Frage16 163939 -024360 105570 251438 323107Frage17 184356 -003943 125988 271856 343525Frage18 227476 039177 169108 314976 386645Frage19 201877 013577 143508 289376 361045Frage20 180297 -008003 121928 267796 339465Frage21 155660 -032639 097291 243160 314829Frage22 151488 -036812 093119 238987 310656Frage23 161188 -027111 102820 248688 320357Frage24 187058 -001241 128690 274558 346227Frage25 181651 -006648 123282 269150 340819Frage26 152881 -035418 094512 240381 312050Frage27 180297 -008003 121928 267796 339465
119
Package eRm
325 Das partial-credit Modell
Der Befehl zur Analyse nach dem partial-credit Modell lautet PCM()
Als Untersuchungsobjekt fuumlr PCM() wird eine Matrix oder Datenframe benoumltigt Die Reihen derMatrix entsprechen den Untersuchungsfaumlllen (n) und die Spalten entsprechen den Ergebnissen derItems
3251 PCM()
Die folgenden Parameter koumlnnen an PCM() uumlbergeben werden
PCM(X W se = TRUE sum0 = TRUE etaStart)
bull X = die zu analysierernde Datenmatrixbull W = optionale Designmatrix zur Normierung auf ein bestimmtes Itemsbull se = Berechnung der Standardfehler (TRUE=ja FALSE=nein)bull sum0 = TRUE=Normierung der Parameter auf sum-0 FALSE=Begrenzung des ersten Parameters
auf 0bull etaStart = optionale Uumlbergabe von vermuteten Parameterschaumltzwerten
326 Das lineare Ratingskalen-Modell
Der Befehl zur Analyse nach dem linearen Ratingskalen-Modell lautet LRSM()
Als Untersuchungsobjekt fuumlr LRSM() wird eine Matrix oder Datenframe benoumltigt Die Reihen derMatrix entsprechen den Untersuchungsfaumlllen (n) und die Spalten entsprechen den Ergebnissen derItems
3261 LRSM()
Die folgenden Parameter koumlnnen an LRSM() uumlbergeben werden
LRSM(X W mpoints = 1 groupvec = 1 se = TRUE sum0 = TRUEetaStart)
bull X = die zu analysierernde Datenmatrixbull W = optionale Designmatrix zur Normierung auf ein bestimmtes Itemsbull mpoints = Anzahl der Messpunktebull groupvec = Vector der Laumlnge N welche die Gruppenzugehoumlrigkeiten enthaumllt Wirdgroupvec=1 gesetzt werden keine Gruppen verwendet
bull se = Berechnung der Standardfehler (TRUE=ja FALSE=nein)bull sum0 = TRUE=Normierung der Parameter auf sum-0 FALSE=Begrenzung des ersten Parameters
auf 0
120
Das lineare partial-credit Modell
bull etaStart = optionale Uumlbergabe von vermuteten Parameterschaumltzwerten
327 Das lineare partial-credit Modell
Der Befehl zur Analyse nach dem linearen partial-credit Modell lautet LPCM()
Als Untersuchungsobjekt fuumlr LPCM() wird eine Matrix oder Datenframe benoumltigt Die Reihen derMatrix entsprechen den Untersuchungsfaumlllen (n) und die Spalten entsprechen den Ergebnissen derItems
3271 LPCM()
Die folgenden Parameter koumlnnen an LPCM() uumlbergeben werden
LPCM(X W mpoints = 1 groupvec = 1 se = TRUE sum0 = TRUEetaStart)
bull X = die zu analysierernde Datenmatrixbull W = optionale Designmatrix zur Normierung auf ein bestimmtes Itemsbull mpoints = Anzahl der Messpunktebull groupvec = Vector der Laumlnge N welche die Gruppenzugehoumlrigkeiten enthaumllt Wirdgroupvec=1 gesetzt werden keine Gruppen verwendet
bull se = Berechnung der Standardfehler (TRUE=ja FALSE=nein)bull sum0 = TRUE=Normierung der Parameter auf sum-0 FALSE=Begrenzung des ersten Parameters
auf 0bull etaStart = optionale Uumlbergabe von vermuteten Parameterschaumltzwerten
328 unterstuumltze Funktionen im eRm-Package
Das eRm-Package enthaumlltunterstuumltzt weitere Funktionen denen Objekte aus der Rasch-Analyseuumlbergeben werden muumlssen
Funktion benoumltigt Output von
bull plotjointICC() bull RM()15
15 Kapitel 322 auf Seite 97
121
Package eRm
bull LRtest()bull plotICC()bull Waldtest()
bull RM()16 PCM()17 RSM()18
bull personparameter()---- andere Packages ----bull coef19()bull confint20()bull logLik21()bull modelmatrix22()bull summary23()bull vcov24()
bull RM()25 PCM()26 RSM()27LLTM()28 LRSM()29 LPCM()30
bull thresholds() bull PCM()31 RSM()32 LRSM()33LPCM()34
bull plotGOF() bull LRtest()
16 Kapitel 322 auf Seite 9717 Kapitel 325 auf Seite 12018 Kapitel 324 auf Seite 11319 httpdewikibooksorgwikiGNU20R3A20coef20 httpdewikibooksorgwikiGNU20R3A20confint21 httpdewikibooksorgwikiGNU20R3A20logLik22 httpdewikibooksorgwikiGNU20R3A20modelmatrix23 httpdewikibooksorgwikiGNU20R3A20summary24 httpdewikibooksorgwikiGNU20R3A20vcov25 Kapitel 322 auf Seite 9726 Kapitel 325 auf Seite 12027 Kapitel 324 auf Seite 11328 Kapitel 323 auf Seite 11329 Kapitel 326 auf Seite 12030 Kapitel 327 auf Seite 12131 Kapitel 325 auf Seite 12032 Kapitel 324 auf Seite 11333 Kapitel 326 auf Seite 12034 Kapitel 327 auf Seite 121
122
unterstuumltze Funktionen im eRm-Package
bull IC()bull itemfit()bull personfit()bull pmat()---- andere Packages ----bull plot35()bull residuals36()
bull personparameter()
35 httpdewikibooksorgwikiGNU20R3A20plot36 httpdewikibooksorgwikiGNU20R3A20residuals
123
33 Package ltm
125
34 Literatur
bull Poinstingl Mair amp Hatzinger (2007) Manual zum Softwarepackage eRm (extended Raschmodeling) Pabst ISBN 9783899674385
bull Mair amp Hatzinger (2007) Extended Rasch modeling The eRm package for the application ofIRT Models in R Journal of Statistical Software 20(9) (PDF)1
bull Rizopoulos (2006) ltm An R Package for Latent Variable Modeling and Item Response AnalysisJournal of Statistical Software 17(5) (PDF)2
1 httpwwwjstatsoftorgv20i092 httpwwwjstatsoftorgv17i05
127
35 Weblinks
bull Rasch-Modell bei Wikipedia1
1 httpdewikipediaorgwikiRasch-Modell
129
36 Datum- und Zeitfunktionen
131
37 Einleitung
Oft sind wir am Zeitpunkt der Datenerhebung interessiert Typischerweise wird dann zusaumltzlich zuden relevanten Variablen eine oder mehrere Variable mit Datum undoder Uhrzeit erhoben Diesgilt ganz besonders fuumlr technische Anwendungen wie zB die Analyse von Messdaten oder dieautomatisierte Auswertung von Log-Dateien
R verfuumlgt uumlber eine Vielzahl an Funktionen um Zeitpunkte zu repraumlsentieren Zeitintervalle zuberechnen oder Zeitreihen zu analysieren die in diesem Kapitel vorgestellt werden
133
38 Grundlegende Datumfunktionen
3801 Umwandeln von Character-Vektoren in Datum-Variablen
Typischerweise liegen Datum-Variablen nach einem Daten-Import nur als character vor
Rgt datensatz$datum[1] 1 Nov 2007 1200[2] 3 Nov 2007 1123[3] 3 Nov 2007 1412[]Rgt class(datensatz$datum)[1] character
Um diese Variable als Datum zu behandeln muumlssen wir definieren in welcher Form das Datumvorliegt Hierzu bietet sich die Funktion strptime()1 an Datumbestandteile und Trennzeichenlassen sich flexibel uumlber den Parameter format angeben Datumsbestandteile beginnen immer miteinem -Zeichen Die Bedeutung dieser Zeichen laumlsst sich uumlber strptime nachlesen fuumlr unserBeispiel funktioniert die folgende Syntax
Rgt datum lt- strptime2(datensatz$datumformat=d b Y R)Rgt datum[1] 2007-11-01 120000[2] 2007-11-03 112300[3] 2007-11-03 141200[]
Rgt class(datum)
[1] POSIXt POSIXlt
Die Variable ist nun als Datum definiert
3802 Einfache Definition von Datum-Variablen
Die Funktion ISOdate(JahrMonatTagStundeMinuteSekunde)3 kann zureinfachen Definition eines Datum-Objekts verwendet werden
1 httpdewikibooksorgwikiGNU20R3A20strptime3 httpdewikibooksorgwikiGNU20R3A20ISOdate
135
Grundlegende Datumfunktionen
tag_der_befreiunglt- ISOdate(194505082301)tag_der_befreiung[1] 1945-05-08 230100 GMT
3803 Aktuelles Datum Systime()
Die Funktion Systime()4 liefert das aktuelle Datum
jetzt lt- Systime()
3804 Berechnen von Zeitintervallen
Zeitintervalle lassen sich mittels der Funktion difftime()5 oder noch einfacher folgendermas-sen berechnen
jetzt - tag_der_befreiungTime difference of 22851 daysintervall lt- (jetzt-tag_der_befreiung)class (intervall)[1] difftime
Angenommen wir interessieren uns eigentlich fuumlr die Stunden seit der offiziellen Kapitulation desNazi-Regimes Dann koumlnnen wir das Objekt intervall vom Typ difftime folgendermassenumrechnen
asnumeric(intervallunits=hours)[1] 548427
3805 Plotten zeitabhaumlngiger Daten
Die Funktion plot()6 verwendet eine spezielle Methode wenn als unabhaumlngige VariableZeitdaten spezifiziert werden
zeitpunkte lt- sort(ISOdate(2007112112023023)) erzeugt 24 Beispiel-Zeitpunkte und sortiert sie zeitlich
werte lt- 124 - 4sin(124) erzeugt 24 Beispielwerteplot(werte˜zeitpunktetype=lxlab=Jahr
4 httpdewikibooksorgwikiGNU20R3A20Systime5 httpdewikibooksorgwikiGNU20R3A20difftime6 httpdewikibooksorgwikiGNU20R3A20plot
136
unterstuumltze Funktionen im eRm-Package
2007ylab=Beispieldaten) Plottet die Zeitreihe alsLiniendiagramm
Abb 7
Die Skalierung und Beschriftung der x-Achse passt sich entsprechend der Zeitspanne der Daten anund wird automatisch entweder in Stunden Tagen Monaten oder Jahren ausgegeben
137
39 Analyse von Zeitreihen
Als einfachste Funktion zur Darstellung von Zeitreihen bietet R den ts Befehl an Dieser ordnet mitder Struktur ts(Datenvektor start=Jahreszahl frequency=Datenpunkte pro Jahr) einer univariatenReihe von Zahlen einen jeweiligen Zeitpunkt beginnend mit dem Startjahr und in der genanntenFrequenz pro Jahr zu
139
40 Block-Randomisierung
401 Einleitung
Innerhalb von klinischen Studien (Clinical Trials) kann es notwendig sein eine Block-Randomisierung durchzufuumlhren
In R steht hierzu zB das Zusatzpaket1 blockrand zur Verfuumlgung
402 blockrand
4021 Installation
Das Paket wird mit folgendem Befehl uumlber das Internet installiert
installpackages(blockrand dependencies=TRUE)
4022 Verwendung
Bevor das Paket genutzt werden kann muss es aktiviert werden per
library(blockrand)
Jetzt kann eine einfache Randomisierungsliste erzeugt werden per
blockrand(1502)
Hierbei werden 150 Probanden zufaumlllig in 2 Gruppen eingeteilt Standardmaumlszligig heissen dieseGruppen A und B Um ihnen eigene Labels zuzuweisen nutzt man die Option levels
blockrand(1502 levels=c(Intervention Placebo))
Auch die Blockgroumlszlige kann angegeben werden
1 Kapitel 7 auf Seite 17
141
Block-Randomisierung
blockrand(1502 blocksizes=2 levels=c(Intervention Placebo))
Hierbei gilt dass der Wert von blocksizes von R mit 2 multipliziert wird um dann Blockgrouml-szligen aller geraden Zahlen innerhalb des Werts zu generieren Wird blocksizes = 2 gewaumlhltgeneriert R zufaumlllig Bloumlcke der Groumlszlige 2 und 4 Wird blocksizes = 3 gewaumlhlt generiert Rzufaumlllig Bloumlcke der Groumlszlige 2 4 und 6
403 siehe auch
142
Teil IV
Programmieren mit R
143
41 Programmieren mit R
Ein weiterer Vorteil von R besteht darin dass man neue Funktionsweisen nach seinen Beduumlrfnissenprogrammieren kann Im Anhang Programmierbeispiele1 werden die hier verwendeten Programmier-beispiele gesammelt
411 Programmieren mit R
In R ist es moumlglich eigene Programme zu schreiben und eigene Zusatzpakete zu entwickeln Elementarfuumlr die Programmierung ist die Moumlglichkeit eigene Funktionen zu definieren und die MoumlglichkeitKontrollstrukturen zu benutzen R erlaubt auch die rekursive Ausfuumlhrung von Funktionen
Fuumlr Programmierer die mit anderen Programmiersprachen arbeiten und sich mit der R-Programmierung vertraut machen wollen sind folgende Unterschiede augenfaumlllig
bull Die Handhabung von Parametern bei Funktionsaufrufen ist in R sehr variable Die erscheinendenSpielarten des Funktionsaufrufe werden in einem spaumlteren Abschnitt erlaumlutert
bull Alle Aufrufe wie zB getwd() sind Methoden auch wenn sie sie im interaktiven Modus wieShell-Kommandos benutzt werden Es sind immer Klammern zu verwenden Der Vorteil ist dasses keine Kollision zwischen Variablennamen und Methodenaufrufen geben kann
bull Die Namen von Methoden lehnen sich an bekannten Kommandonamen an sind aber wie alleNamen in R schwer vorherzusehen So liefert ls() nicht die Auflistung eines Verzeichnissessondern eine Auflistung aller Variablen Auch die in R verwandte Punktsyntax unterscheidet sichzB von jener in Java So wuumlrde man in Java das Erzeugen einer Datentabelle eher in der Formtableread(datacsv) umsetzen In R wird das Verb vor das Objekt gestellt readtable(datencsv)
4111 Iterationen
Iteration Schleifen lassen sich in R auf drei Arten definieren durch
bull die for-Schleifebull die while-Schleifebull die repeat-Schleife
Schleifen bestehen aus zwei Teilen der Schleifenkontrolle und dem Inhalt der Schleife Der Schlei-feninhalt ist ein eigener Programmblock der mit geschweiften Klammern umschlossen wird Wennman mehr als einen Befehl in der Schleife ausfuumlhren moumlchte das ist die Regel dann muumlssen die ein-zelnen Befehle durch Semikolons getrennt werden Jetzt konkret Der Syntax der for-Schleife lautetfor(Variable in Wert)R Befehle in der Schleife Zur Illustration dieser sehr abstrakten Beschreibunghier ein Beispiel
1 Kapitel 54 auf Seite 233
145
Programmieren mit R
gt x = 0gt for(i in 110)x=x+1 print(x)[1] 1[1] 2[1] 3[1] 4[1] 5[1] 6[1] 7[1] 8[1] 9[1] 10
In diesem Beispiel wird innerhalb der Schleife die von 1 bis 10 laumluft die Variable x um eins erhoumlhtund mit print ausgegeben Aufeinander folgende Befehle muumlssen durch das Semikolon getrenntwerden Dieselbe Schleife kann mittels while-Anweisung wie folgt formuliert werden
gt x = 0gt while(xlt10)x=x+1 print(x)[1] 1[1] 2[1] 3[1] 4[1] 5[1] 6[1] 7[1] 8[1] 9[1] 10
Jetzt fehlt nur noch die repeat-Schleife Eigentlich handelt es sich bei der repeat-Schleife um einumgedrehte while-Schleife In R ist es ein wenig komplizierter
gt x = 0gt repeatx=x+1 print(x) if(xgt=10) break[1] 1[1] 2[1] 3[1] 4[1] 5[1] 6[1] 7[1] 8[1] 9[1] 10
Die repeat-Schleife muss explizit per break-Befehl beendet werden Aus diesem Grund kommt hierdie if-Anweisung zum Einsatz Die if-Anweisung dient der bedingten Ausfuumlhrung von BefehlenDiese werden im naumlchsten Abschnitt beschrieben
146
Programmieren mit R
4112 Bedingte Ausfuumlhrung
Innerhalb der Funktion koumlnnen Variablenbedingungen mit dem if()2-Befehl abgefragt werdenDer Aufruf erfolgt etwa so
if3(VARIABLENBEDINGUNG) FUNKTIONSWEISE
Innerhalb der Klammern des if()4-Befehls werden die Variablenbedingungen gesetzt Falls dieseBedingungen erfuumlllt sind wird der Code innerhalb der geschweiften Klammern ausgefuumlhrt FolgendeBedingungen koumlnnen abgefragt werden
Bedingungen== gleich= ungleichlt kleinerlt= kleiner-gleichgt groumlszligergt= groumlszliger-gleich
Verknuumlpfungenampamp und|| oder
Mit diesem Wissen koumlnnten wir nun unsere Funktion etwas erweitern
myfunc lt- function5(x=3y=7)z lt- x+y Die Summe von x und y wird
in z gespeichertif6(zgt20) Abfrage ob die Summer
groumlszliger als 20 istz lt- wow bist du gross wenn ja dann schreibe
einen Text in das Objekt z
return7(z) z wird zuruumlckgemeldet
Mehrere Bedingungen koumlnnen verknuumlpft werden zB so
myfunc lt- function8(x=3y=7)if9(xlt0 amp ylt0) Abfrage ob x und y negativ sind
x lt- x(-1) wenn ja dann mache beidepositiv
y lt- y(-1)
z lt- x+y Die Summe von x und y wird in zgespeichert
if10(z==0 | zgt50) Abfrage ob z gleich 0 oder groumlszliger50 ist
z lt- Summe ist 0 oder groumlszliger 50 wenn ja schreibe
2 httpdewikibooksorgwikiGNU20R3A20if4 httpdewikibooksorgwikiGNU20R3A20if
147
Programmieren mit R
einen Text
return11(z) z wird zuruumlckgemeldet
In der R-Sprache
bull eigene Funktionen programmieren12
412 siehe auch
bull Programmierbeispiele13
bull packageskeleton()14
12 Kapitel 42 auf Seite 14913 Kapitel 54 auf Seite 23314 httpdewikibooksorgwikiGNU20R3A20packageskeleton
148
42 Eigene Funktionen programmieren
In R lassen sich eigene Funktionen problemlos integrieren Die wohl einfachste Methode hierbeiist die Funktionen in der R-Sprache selber zu schreiben Dies wird in den folgenden Abschnittenbeschrieben Weiterhin besteht auch die Moumlglichkeit neue Funktionen in Programmiersprachen wiezB C++ zu programmieren
421 R-Sprache
4211 Funktionsaufbau
Funktionen in R unterscheiden sich von Funktionen in anderen Programmiersprachen wie zB JavaAuffaumlllige Unterschiede sind dass Funktionen in ihrer Signatur keine Ruumlckgabewerte beschreibenDatenkapselung und Zugriffsarten wie sie aus Objektorientierten Programmiersprachen bekanntsind gibt es nicht Man kann Funktionen nicht als private oder public definieren Auch kann manVariablen oder Parameter von Funktionen nicht als final deklarieren Auch eine Fehlermanagementmit zB Exceptions ist in R nicht vorhanden
R-Funktionen werden in der Regel in eigenen Dateien gespeichert Diese R-Skriptdateien kannman mittels source()1 laden Wenn man diese Datei geladen hat kann die darin enthaltenenFunktionen aufrufen Die R-Skriptdateien haben im Vergleich zu anderen Programmiersprachen keineweitere Bedeutung Oft muss man Dinge in R wiederholen dann kann man diese WiederkehrendenProzessschritte in R-Scriptedateien auslagern Dies spart Tipparbeit und macht die Analysen undResultate nachvollziehbar
Zum Erstellen einer eigenen Funktion steht der Befehl function()2 zur Verfuumlgung Dieser istwie folgt aufzurufen
function(Parameter1 Parameter2 ) Anweisungen
In den Klammern direkt nach function3 koumlnnen Parameter benannt werden welche dann beimFunktionsaufruf der Funktion zur Verfuumlgung stehen Innerhalb der geschweiften Klammern wird dieeigentliche Funktionsweise geschrieben Zu beachten dabei ist dass mehrere Anweisungen innerhalbder FUNKTIONSWEISE mit einem Semikolon terminiert werden muumlssen
1 httpdewikibooksorgwikiGNU20R3A20source2 httpdewikibooksorgwikiGNU20R3A20function3 httpdewikibooksorgwikiGNU20R3A20function
149
Eigene Funktionen programmieren
Um eine neue Funktion in R aufrufen zu koumlnnen wird die Funktionsweise einem neuen Objekt (zbmyfunc) zugeordnet
myfunc lt- function(xy) Neue Funktion mit den Parametern x und yz lt- x+y Die Summe von x und y wird in z
gespeichertreturn4(z) z wird zuruumlckgemeldet
Der obigen Funktion myfunc werden im Funktionsaufruf die Parameter x und y uumlbergebenInnerhalb der Funktion wird die Summe aus x und y gebildet und per return()5 an die R-Konsolezuruumlckgemeldet Rufen wir diese Funktion beispielsweise auf mit
myfunc(46)
erhalten wir als Ruumlckmeldung
10
Ein Vorteil von R ist die Moumlglichkeit Standardwerte fuumlr die Parameter vorzugeben welcheverwendet werden falls der Funktionsaufruf ohne diese Parameter erfolgt
myfunc lt- function(x=3y=7) Neue Funktion mit Standardwerten fuumlrdie Parameter x und y
z lt- x+y Die Summe von x und y wird in zgespeichert
return6(z) z wird zuruumlckgemeldet
Rufen wir die Funktion ohne Parameter auf
myfunc()
so werden die Standardwerte genutzt und wir erhalten das Ergebnis
10
Rufen wir die Funktion mit Parametern auf zB
myfunc(124)
so erhalten wir das Ergebnis
5 httpdewikibooksorgwikiGNU20R3A20return
150
siehe auch
16
4212 Schleifen
Mit Schleifen koumlnnen wir gewisse Textstellen in unserer Funktion beliebig bis unendlich oftwiederholen und uns somit Unmengen von Arbeit sparen
Strecke lt- function(x=10y=x) while(a=0alt=a++)
z=z+x z wird zu z+xz=z+y z wird zu z+y
return(z)
z wird zuruumlckgemeldet
422 siehe auch
423 Literatur
424 Weblinks
151
43 Dateioperationen
Eine der wichtigsten Eigenschaften von Programmen ist Kooperation mit anderen Programmen Alsowelche Schnittstellen (engl Interfaces) bietet mein Programm Wie kann ich Daten importierenexportieren und wie kann ich mein Programm steuern In dem ganzen Buch sind schon einzelne Dingewie der Import von Daten beschrieben worden R kann Daten aus verschiedenen Quellen importierendie einfachste Form ist das Einlesen von CSV-Dateien R ermoumlglicht eine Datei-basierte EingabeAusgabe und Steuerung von R Nachfolgend werden alle relevanten R-Funktionen beschrieben diediese Datei-basierte Ein- Ausgabe und Steuerung ermoumlglichen
431 Dateioperationen
Basis fuumlr alle R-Dateioperationen ist das Arbeitsverzeichnis (eng working directory) Alle Datei-operationen beziehen sich auf dieses Verzeichnis es sei denn bei dem Aufruf einer Dateioperationwird explizit etwas anderes angegeben
153
44 Eigene Zusatzpakete erstellen
R wird von einer groszligen Anzahl von Freiwilligen weiter auf- und ausgebaut
Es besteht die Moumlglichkeit sich mit selbsterstellten Funktionen undoder Datensaumltzen am Aufbau zubeteiligen Die gaumlngigste Methode ist seine Daten in einem eigenen Zusatzpaket1 zu buumlndeln unddieses dann uumlber das CRAN der Allgemeinheit zugaumlngig zu machen
441 Paket erstellen
Um die Daten und Funktionen zu einem Paket zu buumlndeln steht die Funktionpackageskeleton()2 zur Verfuumlgung Sie erstellt die erforderlichen Unterverzeichnis-se des Pakets legt die Daten und Funktionen in eben diesen ab und generiert Dummy-Dateien zurDokumentation
4411 Die Paketverzeichnisse
Ein Paket besteht aus einem Hauptverzeichnis (welches den Namen des Pakets haben soll-te) und mehreren Unterverzeichnissen Die benoumltigten Paket-Unterverzeichnisse werden vonpackageskeleton()3 automatisch angelegt
Die Inhalte der Verzeichnisse werden im Folgenden dargestellt
1 Kapitel 7 auf Seite 172 httpdewikibooksorgwikiGNU20R3A20packageskeleton3 httpdewikibooksorgwikiGNU20R3A20packageskeleton
155
Eigene Zusatzpakete erstellen
Hauptverzeichnisbull DESCRIPTION Diese Datei gibt eine
Beschreibung des Pakets Das For-mat ihres Inhalts ist vorgegeben Damit packageskeleton() eine Dummy-DESCRIPTION-Datei angelegt wirdmuumlssen die Inhalte nur noch entsprechendausgefuumlllt bzw ergaumlnzt werdenPackage (Name des Pakets)Type PackageVersion (Paketversion zB 13)Date (Datum des Erstellens zB 2007-06-02)Author (Liste der Autoren mit Kom-mata getrennt)Maintainer (Name des Hauptautorsund dessen E-Mail-Adresse)Depends R (gt= 240)PKGNAME (R-Version und andere be-noumltigte Zusatzpakete)Description (Eine kurze Beschrei-bung des Pakets Sinn und Zweck)License GPL version 2 ornewerURL (einen oder mehrere Links)
Unterverzeichnissebull data In diesem Verzeichnis befinden sich
die Datensaumltze die in dem Paket enthaltenseien sollen
bull man Hier befinden sich alle Dokumenta-tionen im R Dokumentationformat (Rd)Dokumentationen sollten fuumlr alle Daten-saumltze und Funktionen des Pakets erstelltwerden
bull R In diesem Verzeichnis befinden sich dieFunktionen des Pakets
442 Dokumentation schreiben
Dokumentationen werden im R Documentation-Format geschrieben Dies ist eine ASCII-Dateiwelche die Dateiendung Rd besitzt und ins man-Verzeichnis gelegt wird Wie bereits obenbeschreiben legt die Funktion packageskeleton() Dummy-Dokumentations-Dateien zu allen
156
Dokumentation schreiben
Objekten Daten und Funktionen an welche mit dem Paket gebuumlndelt werden sollen Sie muumlssenlediglich noch mit den passenden Infos erweitert werden
4421 Dokumentation zu datasets
Jeder Datensatz muss eine Dokumentationsdatei besitzen Diese ist wie folgt aufzubauen
nameDATENSATZNAME hier wird der Name des DatensatzeseingetragendocTypedata hier muss bei datasets immer data eingetragenwerdentitleKURZBESCHREIBUNG hier kommt eine kurze Uumlberschrift derDaten hindescriptionBESCHREIBUNG hier kommt eine kurze Beschreibung uumlberdie Daten hinusageDATENAUFRUF hier wird beschrieben wie die Datenaufzurufen sind
(dies ist meist der Name desDatensatzes)formatFORMAT hier wird das Datenformat eingetragenalso zB vector matrix data frame
bei Martittzen und Data frames sollteeine Beschreibung der Zeilen und
Spalten gegeben werdenreferencesQUELLEN hiermit koumlnnen Literaturangabenangegeben werdensourceQUELLE hier wird eingetragen woher die Datenstammen (Originalquelle)keyworddatasets hier muss bei datasets immer datasets eingetragenwerden
4422 Dokumentation zu Funktionen
Jede Funktion sollte im man-Verzeichnis eine eigene Dokumentationsdatei erhalten Diese ist wiefolgt aufzubauen
nameFUNKTIONSNAME hier wird der Name der FunktioneingetragenaliasALIASNAME Falls mehrere Funktionen auf die selbeHelp-Seite verweisen
werden diese hier mit je eineralias-Zeile aufgelistettitleKURZBESCHREIBUNG hier kommt eine kurze Uumlberschrift derFunktion hindescriptionBESCHREIBUNG hier kommt eine kurze Beschreibung uumlberdie Funktionsweise
der Funktion hinusageFUNKTIONSAUFRUF hier wird beschrieben wie die Funktionaufzurufen ist
zB function(argument1 argument2)arguments hier werden die Argumente dieuumlbergeben werden koumlnnen
itemARGUMENT1 durch die Aufzaumlhlung itembeschrieben
itemARGUMENT2
157
Eigene Zusatzpakete erstellen
detailsDETAILS hier kommt eine exakte Beschreibunghin welche den description
-Part ergaumlnzt und erweitertreferencesQUELLEN hiermit koumlnnen Quellenangaben angegebenwerdennoteNOTIZ hier koumlnnen Notizen eingetragen werdenauthorAUTOR Informationen uumlber die Autoren URLsund E-Mail koumlnnen innerhalb
per urlhttpwwwfoobar undemailemailde angegeben werdenexamplesBEISPIELE innerhalb der Klammern koumlnnenBeispielaufrufe formuliert werdenkeywordkeyword1 Hier muss mindestens ein R-Keywordgesetzt werden Fuumlr eine Uumlbersichtkeywordkeyword2 an Keywords tippen Sie ein fileshow(filepath(Rhome(doc)KEYWORDS))
4423 Dokumentation zum Paket
Im Gegensatz zu Datensaumltzen und Funktionen muss die Dummy-Dokumentations-Datei zurPaketdokumentation mit dem Befehl promptPackage()4 angelegt werden Die einzig geforderteAngabe innerhalb dieser Datei ist
docTypepackage das package muss so stehen bleiben
443 Paket uumlberpruumlfen und fertig stellen
Wenn man alle oben aufgefuumlhrten Schritte durchgefuumlhrt hat ist es an der Zeit das Paket fertigzu-stellen Bevor dies geschieht muss das Paket allerdings noch auf Fehler uumlberpruumlft werden Diesgeschieht in der Shell Man geht hierzu in das Verzeichnis in welchem das Hauptverzeichnis desPakets (als Unterverzeichnis) liegt und tippt in die Shell den folgenden Befehl ein
R CMD check PAKETNAME
Da das Paketverzeichnis den Namen des Pakets tragen sollte (so) weiss das Script wo es nachDaten suchen muss Nun wird das Paket auf moumlgliche Fehler hin uumlberpruumlft Es ist wichtig dass manerst weiter arbeitet wenn diese Routine fehlerfrei durchlaumluft
Ist die Uumlberpruumlfung fehlerfrei verlaufen kann das Paket zu einer targz-Datei geschnuumlrt werdenHierzu gibt man in die Shell ein
R CMD build PAKETNAME
4 httpdewikibooksorgwikiGNU20R3A20promptPackage
158
Paket zum CRAN hochladen
Das Script holt sich die passenden Versions-Informationen aus der DESCRIPTION-Datei so dassdie tar-Datei (entsprechend der Version) automatisch als zB PKGNAME_112targz erstelltwird
444 Paket zum CRAN hochladen
Das fertige Paket kann nun per FTP zum CRAN hochgeladen werden Die URL lautet
bull ftpcranR-projectorgincomingbull Username anonymousbull Passwort (Ihre E-Mail-Adresse)
Mit der als Passwort angegebenen Adresse muss dann eine Info-Mail an cranr-projectorg5
gesendet werden Das Paket wird zunaumlchst auf moumlgliche Fehler uumlberpruumlft und anschlieszligend demCRAN hinzugefuumlgt
445 Weblinks
bull Writing R Extensions (PDF)6
bull Das wikibooks-Paket7 BROKEN LINKbull Pakete erstellen8
5 mailtocranr-projectorg6 httpcranr-projectorgdocmanualsR-extspdf7 httpcranatr-projectorgsrccontribDescriptionswikibookshtml8 httpwwwr-statistikdeR_erweiternPaketepaketehtml
159
45 Andere Programmiersprachen einbinden
Auch andere Programmiersprachen koumlnnen eingebunden werden wie zB
451 C++
452 Java
161
46 Finden von Programmfehlern undDebugging
Ursache von Programmfehlern sind zumeist Fehlannahmen uumlber die von (Unter-)Funktionen zuruumlck-gegebenen Inhalte oder Datentypen der uumlbergebenen Objekte Oft ist es deshalb wuumlnschenswert denZustand beim Programmabbruch genauer zu analysieren R stellt hierfuumlr verschiedene Methoden undOptionen zur Verfuumlgung
R unterstuumltzt das Auffinden von Fehlern mit mehreren Hilfsfunktionen und Optionen Welche bei derFehlersuche eingesetzt werden haumlngt letztlich von Vorlieben der ProgrammiererInnen ab DieserAbschnitt soll einen Uumlberblick uumlber die Moumlglichkeiten geben
461 Manuelles Einfuumlgen von Ausgabewerten
R gibt zumeist relativ praumlzise Fehlermeldungen warum ein Programmabbruch erfolgt ist aberleider keine Zeilenangaben Dies erschwert es manchmal die genaue Stelle zu finden an der derFehler auftrat Daher ist es oft sinnvoll mehrere print oder cat-Funktionen mit unterscheidbarerAusgabe an verschiedenen Stellen zu setzen Falls die entsprechende Ausgabe erfolgt ist der Fehleran dieser Stelle noch nicht aufgetreten
Wenn eingegrenzt werden konnte wo der Fehler auftritt macht es Sinn sich die Zustaumlnde der derFunktion uumlbergebenen Objekte an charakteristischen Stellen mit print ausgeben zu lassen Je nachFehlermeldung sind auch die Funktionen length und class sehr nuumltzlich bei der Fehlersuche
462 Gaumlngige Fehler
Wie bereits erwaumlhnt treten Fehler haumlufig deshalb auf weil Funktionen andere Objekte uumlbergebenwerden als diese erwarten Wer verstanden hat wie Objektklassen funktionieren duumlrfte auch diemeisten der Fehlermeldungen verstehen Dennoch kann die Interpretation von Fehlermeldungen unddie Fehlersuche in R nicht nur Anfaumlngern immer wieder Schwierigkeiten bereiten
Hier sollen ein paar haumlufige Fehler und Loumlsungen beschrieben werden
bull Manchmal ist es nicht ganz einfach zu verstehen welche Klasse eine Funktion erwartet Auskunfthieruumlber gibt immer die Hilfe-Seite einer Funktion Hier wird meist genau unter argumentsbeschrieben was die Funktion an Eingabeobjekten erwartet Unter value sind die Objekte undderen Klasse beschrieben die die Funkton zuruumlckgibt
bull Problematisch ist zB die Klasse factor Sie verhaumllt sich aus Nutzersicht wie ein character-Vektor besteht aber in Wahrheit aus Elementen vom Typ numeric Dies ist insbesondere beimDatenimport aus Dateien (zB mit readcsv) problematisch wenn Spalten mit Nummern
163
Finden von Programmfehlern und Debugging
(zB wegen zusaumltzlicher Buchstaben) als Strings importiert und auf Grund der Einstellungenautomatisch ein factor erzeugt werden Eine Konvertierung in asnumeric gibt dann unterUmstaumlnden nicht die erwarteten Werte zuruumlck sondern die interne Repraumlsentation des factorEine korrekte Behandlung erfordert in diesem Fall kontraintuitives Vorgehen asnumeric (ascharacter ( variable ) )
bull Listenreferenzierungen sorgen bei Anfaumlngern ebenfalls oft fuumlr Verwirrung
463 Error-Recovery mit dem Browser
Eine der nuumltzlichsten Einstellungen betrifft die Frage was passiert wenn ein Fehler aufgetreten istDies kann uumlber options(error) festgelegt werden Standardmaumlssig wird eine Fehlermeldungdargestellt und die Programmausfuumlhrung abgebrochen options(error=print) Stattdessenkann aber mit options(error=recover) im Fehlerfall auch automatisch ein so genannterBrowser gestartet werden Dies soll in einem Beispiel verdeutlicht werden Einem dataframewerden statt Vektoren oder Listen der Code der Funktion sum uumlbergeben
gt options(error=print)gt dataframe(110sum)
Fehler in asdataframedefault(x[[i]] optional = TRUE)
kann Klasse function nicht in dataframe umwandeln
Wenn options(error=recover) gesetzt wird springt R in den browser
gt options(error=recover)gt dataframe(110sum)Fehler in asdataframedefault(x[[i]] optional = TRUE)
kann Klasse function nicht in dataframe umwandeln
Enter a frame number or 0 to exit
1 dataframe(110 sum)
2 asdataframe(x[[i]] optional = TRUE)
3 asdataframedefault(x[[i]] optional = TRUE)
Auswahl _
164
Error-Recovery mit dem Browser
Der Browser dient dazu durch die Hierarchien des Funktionsaufrufs (sogenannte frames) zumZeitpunkt des Fehlers zu navigieren In diesem Fall gibt es drei frames Den Funktionsaufruf (1)und zwei von der Funktion dataframe aufgerufene Unterfunktionen (2 und 3)
Die Browser hat zwei Zustaumlnde
bull frame-Auswahl In der frame-Auswahl kann durch Eingabe der entsprechenden Nummern inden entsprechenden frame gesprungen werden
bull frame-Editor Im frame-Editor koumlnnen alle Funktionen und Kommandos wie gewoumlhnlichbenutzt werden Insbesondere werden Objekte durch einfache Eingabe ihres Namens ausgegebenDurch eine Leereingabe RETURN springt der Browser zuruumlck in die frame-Auswahl
Waumlhlen wir beispielsweise frame 1 unseren urspruumlnglichen Funktionsaufruf in dem wir 1eingeben
Auswahl 1
Called from dataframe(110 sum)
Wir befinden uns nun in frame 1 und koumlnnen die Objekte dort betrachten Um alle Objekte desframe aufzulisten benutzen wir die Funktion ls()
ls()[1] checknames checkrows datarownames i[5] mrn n namesi
ncols[9] novn nrows object
rownames[13] stringsAsFactors tmpname vlistvnames
[17] x xi
Dies sind alles Variablen die die Funktion dataframe() intern bei der Erstellung neuer Objektegeneriert Uns interessieren hier beispielhaft die der Funktion dataframe uumlbergegebenen Wertedie in x gespeichert sind
[[1]]
[1] 1 2 3 4 5 6 7 8 9 10
[[2]]
function ( narm = FALSE) Primitive(sum)
Erkennbar ist dass eine Liste mit zwei Werten uumlbergeben wurde Das Listenelement [[1]] enthaumlltdie Werte 110 das Listenelement [[2]] die Funktion sum
165
Finden von Programmfehlern und Debugging
Wir verlassen den Browser durch eine Leereingabe (RETURN) (zum Wechseln in die frame-Auswahl) und die Eingabe einer 0 (zum Beenden des Browsers)
Derart lassen sich alle Werte zum Zeitpunkt des Programmabbruchs untersuchen Wenn ein Fehlerauftritt und nicht klar ist welche Funktionen zum Fehler fuumlhrten und welche Werte vorher uumlbergebenwurden sollte generell options(error=recover) gesetzt werden Die error-recovery kannnach der Korrektur der Fehler mit options(error=print) wieder deaktiviert werden
464 Verfolgen von Funktionen mit trace
166
Teil V
Anhang
167
47 Anwendungsbeispiele
In diesem Anhang finden sich Anwendungsbeispiele und -datensaumltze die zum Testen der beschriebe-nen R-Funktionen dienen
169
48 Datenbeispiele
481 Beispiel 1
Geschlecht Alter Gewicht Groessem 28 80 170w 18 55 174w 25 74 183m 29 101 190m 21 84 185w 19 74 178w 27 65 169w 26 56 163m 31 88 189m 22 78 184
R-Befehl zum Erzeugen dieser Tabelle
w lt- factor1(c2(m w w m m w w w m m))x lt- c3(28 18 25 29 21 19 27 26 31 22)y lt- c4(80 55 74 101 84 74 65 56 88 78)z lt- c5(170 174 183 190 185 178 169 163 189 184)bsp1 lt- dataframe6(w x y z)colnames7(bsp1) lt- c(Geschlecht Alter Gewicht Groesse)rm8(w x y z)bsp1
482 Beispiel 2
Geschlecht Notem 2w 1m 5m 3w 4m 3w 2w 2w 1m 3m 1w 4m 2w 1m 4m 3w 5
171
Datenbeispiele
m 2w 1w 2
R-Befehl zum Erzeugen dieser Tabelle
x lt- factor9(c10(m w m m w m w w w m m wm w m m w m w w))y lt- c11(21534322131421435212)bsp2 lt- dataframe12(xy)colnames13(bsp2) lt- c(Geschlecht Note)rm14(xy)bsp2
483 Beispiel 3
Erfolg Abschlussnote1 0 52 1 33 1 24 0 45 1 16 0 67 1 38 1 29 0 410 1 311 0 612 0 513 0 414 1 3
R-Befehl zum Erzeugen dieser Tabelle
a lt- factor15(c16(0 1 1 0 1 0 1 1 0 1 0 0 0 1))b lt- c17(5 3 2 4 1 6 3 2 4 3 6 5 4 3)bsp3 lt- dataframe18(ab)colnames19(bsp3) lt- c(Erfolg Abschlussnote)rm20(ab)bsp3
484 Beispiel 4
Name Geschlecht Lieblingsfarbe Einkommen1 Hans maennlich gruen 12332 Caro weiblich blau 8003 Lars intersexuell gelb 24004 Ines weiblich schwarz 40005 Samira weiblich gelb 8996 Peter maennlich gruen 11007 Sarah weiblich blau 1900
172
Beispiel 5
R-Befehl zum Erzeugen dieser Tabelle
w lt- c21(HansCaroLarsInesSamiraPeterSarah)x lt- factor22(c23(maennlichwe
iblichintersexuellweiblichweiblichmaennlichweiblich))y lt- factor24(c25(gruenblaugelbschwarzgelbgruenblau))z lt- c26(12338002400400089911001900)bsp4 lt- dataframe27(wxyz)colnames28(bsp4) lt- c(Name Geschlecht Lieblingsfarbe Einkommen)rm29(wxyz)bsp4
485 Beispiel 5
Lebenstag Gewicht1 1 31802 3 29603 6 32204 11 32705 12 33506 15 34107 19 37008 23 38309 28 409010 33 431011 35 436012 39 452013 47 465014 60 531015 66 549016 73 5540
R-Befehl zum Erzeugen dieser Tabelle
x lt- c30(1 3 6 11 12 15 19 23 28 33 35 39 47 60 66 73)y lt- c31(3180 2960 3220 3270 3350 3410 3700 3830 4090 43104360 4520 4650 5310 5490 5540)bsp5 lt- dataframe32(xy)colnames33(bsp5) lt- c(Lebenstag Gewicht)rm34(xy)
486 Beispiel 6
Person Date Age Sex DimBody DimEmotion DimSelf DimFamilyDimFriends DimSchool TotalScore
1 190053 2008-08-20 15 f 7500 8500 6500 85007000 9000 7833
2 190050 2008-01-24 16 m 8000 8000 7500 65007000 6000 7167
3 190052 2008-02-05 11 m 7000 6500 3500 80004500 9500 6500
4 190002 2006-12-07 11 f 8500 9000 8500 70008000 5500 7750
5 190002 2008-01-31 13 f 7500 9000 7500 5500
173
Datenbeispiele
8500 7000 75006 190005 2007-02-22 12 m 6500 9000 7000 9500
7500 6500 76677 190035 2007-05-22 14 f 6000 8500 6500 7500
8000 5500 70008 190021 2006-08-30 16 f 5500 5000 5000 3000
5500 5500 49179 190014 2006-12-07 12 m 7500 9000 4000 8500
7500 6000 708310 190029 2006-11-21 13 f 5500 7000 6000 6500
8500 5500 650011 190025 2006-12-07 12 f 10000 9500 9500 10000
9000 8500 941712 190025 2007-02-20 13 f 8500 9500 8500 8500
9500 7500 866713 190036 2007-06-05 12 m 5500 7500 8000 8500
9000 7500 766714 190031 2007-02-13 13 f 6000 8000 6000 8000
9000 5500 708315 190034 2007-05-19 16 f 5000 5500 4500 8000
7000 3000 550016 190044 2007-10-23 13 m 7500 6500 6000 8500
6000 7500 700017 190041 2007-08-16 16 f 9000 9000 9000 10000
7000 6000 833318 190046 2007-11-15 14 f 7000 7500 9000 7000
8000 7500 766719 190034 2007-07-19 16 f 5000 6000 4500 9000
7500 5500 625020 191028 2006-10-26 7 f 6667 10000 10000 6667
5000 8333 777821 191035 2007-05-22 6 f 6667 8333 6667 1000010000 10000 861122 191037 2007-05-31 6 m 6667 8333 10000 8333
6667 8333 805623 191036 2007-06-19 6 f 10000 8333 10000 8333
8333 6667 861124 192052 2008-02-05 8 f 8000 6000 6000 8000
7500 6500 700025 190028 2006-10-26 9 f 6500 6500 6000 8000
7500 7500 700026 190028 2008-02-15 11 f 8500 9000 7000 9500
9000 9000 866727 191028 2008-02-16 9 f 8000 9500 10000 9500
8000 8500 891728 190039 2007-05-29 9 f 7000 9000 8000 9500
9000 9500 866729 190037 2007-05-31 8 m 9000 7500 6000 10000
9000 8000 825030 191030 2007-02-22 9 f 8000 7500 6000 8500
8500 6000 741731 192030 2007-02-22 8 m 8500 9500 6000 8500
6000 8000 775032 190030 2007-02-22 11 f 7000 9000 6000 6500
8000 5500 700033 190022 2006-05-07 10 m 9500 9500 8000 8500
5000 6500 783334 190048 2008-01-08 11 f 6500 7500 6000 8500
7000 6000 691735 190017 2007-12-18 8 f 4000 8000 7000 6000
5500 7500 633336 190015 2006-11-28 12 f 6000 6000 6000 7500
9000 8000 708337 191002 2008-01-31 9 f 8000 10000 9000 7000
9500 6500 833338 271050 2008-01-31 13 m 8500 6500 7000 7000
7000 7000 716739 270050 2008-01-31 16 m 5500 6000 6000 5500
174
Beispiel 6
7000 5000 583340 270052 2008-02-05 11 m 4000 4500 5500 6500
4000 6500 516741 271052 2008-02-05 10 m 8500 4500 4000 7000
5000 5500 575042 272052 2008-02-05 8 f 6000 5500 7000 7000
8000 7500 683343 271002 2007-02-22 8 f 8000 6500 6500 7500
4000 6000 641744 271002 2007-01-26 8 f 8500 8000 8000 7500
8000 9000 816745 270002 2007-01-26 12 f 7500 8500 9000 7000
9500 7500 816746 271002 2008-01-31 9 f 6000 6000 6500 6000
7000 7500 650047 270002 2008-01-31 13 f 8000 7000 9000 7000
8500 8000 791748 270005 2007-01-23 12 m 6500 4500 4500 4500
5000 6000 516749 270005 2007-01-23 12 m 6500 5500 4500 3500
5500 5500 516750 270010 2007-05-22 9 f 7000 6500 7500 9000
5000 9500 741751 270014 2007-04-18 13 m 7500 6500 5000 6500
3000 6500 583352 270022 2006-12-07 10 m 8500 9000 7500 10000
5500 7000 791753 270025 2006-11-30 12 f 10000 8000 8000 8500
9500 9500 891754 270025 2007-02-20 13 f 9000 9500 8000 8000
9500 9500 891755 270028 2006-10-26 9 f 5500 6500 6000 4500
5000 3500 516756 270028 2008-02-16 11 f 5500 4500 5000 5000
5000 5500 508357 270029 2006-11-21 13 f 7000 5000 7000 5000
8500 8000 675058 271030 2006-12-14 9 f 3500 6500 6000 5500
7500 4500 558359 270030 2006-12-14 11 f 6000 5500 3500 6000
6000 5500 541760 270035 2007-05-22 14 f 6000 6000 5500 6500
9000 5500 641761 270036 2007-06-05 12 m 8000 6000 6500 8000
7000 8500 733362 270036 2007-06-19 12 m 6000 5500 7500 7500
6500 8500 691763 270037 2007-05-31 8 m 8000 9000 7500 8500
9500 8500 850064 270039 2007-05-29 9 f 4500 8000 7000 9000
9500 8500 775065 270041 2007-08-16 16 f 8500 9500 7500 7500
9000 7000 816766 270044 2007-10-23 13 m 6000 6500 5500 7500
5500 5000 600067 270046 2007-11-15 14 f 6000 7000 6500 8000
6000 8000 691768 270048 2008-01-08 11 f 6000 6000 5500 8000
7500 5000 633369 270002 2007-02-22 12 f 7000 7500 6500 5500
7500 6000 666770 270004 2006-11-25 14 f 9000 10000 10000 9500
8500 10000 950071 270017 2007-12-13 8 f 6000 8000 6500 8500
5000 8000 700072 271028 2008-02-16 9 f 9500 7500 7500 7000
8000 7500 783373 270015 2006-11-28 12 f 8500 9000 8500 7500
175
Datenbeispiele
8500 9500 858374 271036 2007-06-19 6 f 8500 8500 8000 6000
9500 8000 808375 270045 2007-10-23 7 m 7500 8000 5500 7000
6000 7500 691776 270040 2007-08-07 5 f 9000 7000 7500 7500
6500 7000 741777 271037 2007-05-31 6 m 8000 9000 8000 9500
8000 5500 800078 271035 2007-05-22 7 f 8000 10000 8500 8000
7500 7500 825079 271010 2007-05-22 6 m 10000 6500 7000 9000
7500 8000 800080 270033 2007-03-22 4 m 8000 8000 9000 7500
7500 6500 775081 271036 2007-06-05 7 f 6000 8000 7000 8500
8500 6500 741782 271028 2006-10-26 7 f 9500 8500 8000 9000
7000 6500 8083
R-Befehl zur Erzeugung des Datensatzes
bsp6 lt- structure(list(Person = c(190053 190050 190052190002 190002 190005
190035 190021 190014 190029 190025 190025190036 190031 190034
190044 190041 190046 190034 191028 191035191037 191036 192052
190028 190028 191028 190039 190037 191030192030 190030 190022
190048 190017 190015 191002 271050 270050270052 271052 272052
271002 271002 270002 271002 270002 270005270005 270010 270014
270022 270025 270025 270028 270028 270029271030 270030 270035
270036 270036 270037 270039 270041 270044270046 270048 270002
270004 270017 271028 270015 271036 270045270040 271037 271035
271010 270033 271036 271028) Date =structure(c(1219183200 1201129200
1202166000 1165446000 1201734000 1172098800 11797848001156888800 1165446000
1164063600 1165446000 1171926000 1180994400 11713212001179525600 1193090400
1187215200 1195081200 1184796000 1161813600 11797848001180562400 1182204000
1202166000 1161813600 1203030000 1203116400 11803896001180562400 1172098800
1172098800 1172098800 1146952800 1199746800 11979324001164668400 1201734000
1201734000 1201734000 1202166000 1202166000 12021660001172098800 1169766000
1169766000 1201734000 1201734000 1169506800 11695068001179784800 1176847200
1165446000 1164841200 1171926000 1161813600 12031164001164063600 1166050800
1166050800 1179784800 1180994400 1182204000 11805624001180389600 1187215200
1193090400 1195081200 1199746800 1172098800 11644092001197500400 1203116400
1164668400 1182204000 1193090400 1186437600 11805624001179784800 1179784800
176
Beispiel 6
1174518000 1180994400 1161813600) class = c(POSIXtPOSIXct ) tzone = )
Age = c(15 16 11 11 13 12 14 16 12 13 12 13 12 1316 13 16 14 16 7 6
6 6 8 9 11 9 9 8 9 8 11 10 11 8 12 9 13 1611 10 8 8 8 12 9 13
12 12 9 13 10 12 13 9 11 13 9 11 14 12 12 8 916 13 14 11 12 14 8
9 12 6 7 5 6 7 6 4 7 7) Sex = structure(c(1L 2L2L 1L 1L 2L 1L 1L 2L
1L 1L 1L 2L 1L 1L 2L 1L 1L 1L 1L 1L 2L 1L 1L 1L1L 1L 1L 2L 1L 2L
1L 2L 1L 1L 1L 1L 2L 2L 2L 2L 1L 1L 1L 1L 1L 1L2L 2L 1L 2L 2L 1L 1L
1L 1L 1L 1L 1L 1L 2L 2L 2L 1L 1L 2L 1L 1L 1L 1L1L 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 506667 6667 6667 100 80
65 85 80 70 90 80 85 70 95 65 40 60 80 85 55 4085 60 80 85 75 60 80
65 65 70 75 85 100 90 55 55 70 35 60 60 80 6080 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 1008333 8333 8333 60 65
90 95 90 75 75 95 90 95 75 80 60 100 65 60 4545 55 65 80 85 60 70
45 55 65 65 90 80 95 65 45 50 65 55 60 60 55 9080 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 6667100 100 60 60 70 100
80 60 60 60 60 80 60 70 60 90 70 60 55 40 70 6580 90 65 90 45 45
75 50 75 80 80 60 50 70 60 35 55 65 75 75 70 7555 65 55 65 100 65
75 85 80 55 75 80 85 70 90 70 80) DimFamilie = c(8565 80 70 55 95 75
30 85 65 100 85 85 80 80 85 100 70 90 6667 1008333 8333 80 80 95 95
95 100 85 85 65 85 85 60 75 70 70 55 65 70 7075 75 70 60 70 45 35
90 65 100 85 80 45 50 50 55 60 65 80 75 85 9075 75 80 80 55 95 85
70 75 60 70 75 95 80 90 75 85 90) DimFriends = c(7070 45 80 85 75 80 55
75 85 90 95 90 90 70 60 70 80 75 50 100 66678333 75 75 90 80 90 90
85 60 80 50 70 55 90 95 70 70 40 50 80 40 80 9570 85 50 55 50 30 55
95 95 50 50 85 75 60 90 70 65 95 95 90 55 60 7575 85 50 80 85 95
60 65 80 75 75 75 85 70) DimSchool = c(90 60 95 5570 65 55 55 60 55 85
75 75 55 30 75 60 75 55 8333 100 8333 6667 6575 90 85 95 80 60 80
55 65 60 75 80 65 70 50 65 55 75 60 90 75 75 8060 55 95 65 70 95 95
35 55 80 45 55 55 85 85 85 85 70 50 80 50 60100 80 75 95 80 75 70
55 75 80 65 65 65) TotalScore = c(7833 7167 65 77575 7667 70 4917
177
Datenbeispiele
7083 65 9417 8667 7667 7083 55 70 8333 7667625 7778 8611 8056
8611 70 70 8667 8917 8667 825 7417 775 707833 6917 6333 7083
8333 7167 5833 5167 575 6833 6417 8167 816765 7917 5167 5167
7417 5833 7917 8917 8917 5167 5083 675 55835417 6417 7333 6917
85 775 8167 60 6917 6333 6667 95 70 7833 85838083 6917 7417 80
825 80 775 7417 8083)) Names = c(Person DateAge Sex DimBody
DimEmotion DimSelf DimFamily DimFriendsDimSchool TotalScore) rownames
= c(NA -82L) class = dataframe)
487 Beispiel 7
Die Ergebnisse eines Hochsprungwettbewerbs lauten wie folgt
bull 0 bedeutet dass die entsprechende Houmlhe nicht uumlbersprungen wurdebull 1 bedeutet dass die entsprechende Houmlhe uumlbersprungen wurde
100 110 120 130 150 160 170 190 200 220Hans 1 1 1 1 1 1 1 1 1 1Karola 1 1 1 1 1 1 1 1 1 0Matthias 1 1 1 1 1 1 1 1 0 0Stefan 1 1 1 1 1 1 1 0 0 0Sabine 1 1 1 1 1 1 1 0 0 0Irma 1 1 1 1 1 1 0 0 0 0Heike 1 1 1 1 1 1 0 0 0 0Ralf 1 1 1 1 1 1 0 0 0 0Rainer 1 1 1 1 1 0 0 0 0 0Simon 1 1 1 1 1 0 0 0 0 0Andreas 1 1 1 1 1 0 0 0 0 0Elke 1 1 1 1 0 0 0 0 0 0Gabi 1 1 1 1 0 0 0 0 0 0David 1 1 1 1 0 0 0 0 0 0Jonas 1 1 1 1 0 0 0 0 0 0Nicklas 1 1 1 1 0 0 0 0 0 0Sandra 1 1 1 0 0 0 0 0 0 0Mario 1 1 1 0 0 0 0 0 0 0Guido 1 1 1 0 0 0 0 0 0 0Lisa 1 1 1 0 0 0 0 0 0 0Peter 1 1 1 0 0 0 0 0 0 0Justus 1 1 1 0 0 0 0 0 0 0Josef 1 1 1 0 0 0 0 0 0 0Brigitte 1 1 1 0 0 0 0 0 0 0Kevin 1 1 0 0 0 0 0 0 0 0Marcel 1 1 0 0 0 0 0 0 0 0Nadine 1 1 0 0 0 0 0 0 0 0Alex 1 1 0 0 0 0 0 0 0 0Katharina 1 1 0 0 0 0 0 0 0 0Daniel 1 1 0 0 0 0 0 0 0 0Jens 1 1 0 0 0 0 0 0 0 0Dieter 1 0 0 0 0 0 0 0 0 0Sebastian 1 0 0 0 0 0 0 0 0 0Anne 1 0 0 0 0 0 0 0 0 0
178
Beispiel 8
Diese Tabelle wird wie folgt erzeugt
hochsprung lt- structure(c(1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 0 0 0 0 0 0 0 00 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 11 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 1 1 1 11 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 1 1 1 1 1 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 1 1 1 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 1 1 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) Dim =c(34L 10L) Dimnames = list( c(Hans KarolaMatthias Stefan Sabine Irma Heike RalfRainer Simon Andreas Elke Gabi DavidJonas Nicklas Sandra Mario Guido LisaPeter Justus Josef Brigitte Kevin MarcelNadine Alex Katharina Daniel Jens DieterSebastian Anne) c(100 110 120 130150 160 170 190 200 220)))
488 Beispiel 8
Die Ergebnisse eines Minigolfwettbewerbs lauten wie folgt
bull 0 bedeutet dass das entsprechende Loch nicht mit einem Schlag getroffen wurdebull 1 bedeutet dass die entsprechende Loch mit einem Schlag getroffen wurde
Loch1 Loch2 Loch3 Loch4 Loch5 Loch6 Loch7 Loch8 Loch9Loch10Hans 0 1 1 0 1 1 0 1 11Karola 1 0 1 1 1 0 1 1 10Matthias 1 1 1 0 1 1 1 1 00Stefan 0 0 1 1 0 1 1 0 01Sabine 1 1 1 1 1 1 1 0 00Irma 1 1 0 1 1 1 0 1 00Heike 1 0 1 0 1 1 0 0 01Ralf 1 1 1 0 1 1 0 0 00Rainer 1 1 0 1 1 0 0 1 01Simon 1 0 1 1 1 0 1 0 10
Andreas 1 1 1 0 1 0 0 0 0
179
Datenbeispiele
0Elke 1 1 0 1 0 1 0 0 10Gabi 0 1 1 1 0 0 1 0 01David 1 1 0 1 0 0 0 0 00
Jonas 1 1 0 1 1 0 1 1 00Nicklas 1 1 1 1 0 1 0 0 10Sandra 0 1 0 0 1 0 1 1 01Mario 1 0 1 0 1 1 0 0 00Guido 1 1 1 0 0 0 0 0 10Lisa 0 1 1 0 0 0 1 0 00Peter 1 0 1 0 1 0 0 0 10
Justus 1 1 1 0 0 0 1 0 01
Josef 1 0 1 0 0 0 0 0 00Brigitte 1 1 1 0 0 0 1 0 10Kevin 0 1 0 0 1 0 0 1 01Marcel 1 1 0 0 0 0 0 0 00Nadine 1 0 0 1 0 1 0 0 10
Alex 1 0 0 0 0 0 0 0 00Katharina 0 1 0 0 0 1 1 0 11Daniel 1 1 0 0 0 0 0 0 00
Jens 1 1 0 1 0 0 1 0 10Dieter 1 0 0 0 0 0 1 1 00Sebastian 1 0 1 0 1 0 0 0 11
Anne 0 0 0 0 1 0 1 0 01
Diese Tabelle wird wie folgt erzeugt
minigolf lt- structure(list(Loch1 = c(0 1 1 0 1 1 1 1 1 11 1 0 1 1 1 0 1 1 0 1 1 1 1 01 1 1 0 1 1 1 1 0) Loch2 = c(1 0 1 0 1 1 0 1 1 01 1 1 1 1 1 1 0 1 1 0 1 0 1 11 0 0 1 1 1 0 0 0) Loch3 = c(1 1 1 1 1 0 1 1 0 11 0 1 0 0 1 0 1 1 1 1 1 1 1 00 0 0 0 0 0 0 1 0) Loch4 = c(0 1 0 1 1 1 0 0 1 10 1 1 1 1 1 0 0 0 0 0 0 0 0 00 1 0 0 0 1 0 0 0) Loch5 = c(1 1 1 0 1 1 1 1 11 1 0 0 0 1 0 1 1 0 0 1 0 0 0 10 0 0 0 0 0 0 1 1) Loch6 = c(1 0 1 1 1 1 1 1 0 00 1 0 0 0 1 0 1 0 0 0 0 0 0 00 1 0 1 0 0 0 0 0 ) Loch7 = c(0 1 1 1 1 0 0 0 0 10 0 1 0 1 0 1 0 0 1 0 1 0 1 0
180
Beispiel 9
0 0 0 1 0 1 1 0 1) Loch8 = c(1 1 1 0 0 1 0 0 10 0 0 0 0 1 0 1 0 0 0 0 0 0 0 10 0 0 0 0 0 1 0 0) Loch9 = c(1 1 0 0 0 0 0 0 0 10 1 0 0 0 1 0 0 1 0 1 0 0 1 0 01 0 1 0 1 0 1 0 ) Loch10 = c(1 0 0 1 0 0 1 0 1 00 0 1 0 0 0 1 0 0 0 0 1 0 0 1 0 00 1 0 0 0 1 1)) Names = c(Loch1 Loch2 Loch3Loch4 Loch5 Loch6 Loch7 Loch8 Loch9Loch10 ) class = dataframe rownames = c(Hans KarolaMatthias Stefan Sabine Irma HeikeRalf Rainer Simon Andreas Elke Gabi DavidJonas Nicklas Sandra Mario GuidoLisa Peter Justus Josef Brigitte Kevin MarcelNadine Alex Katharina Daniel JensDieter Sebastian Anne))
489 Beispiel 9
Ein Fragebogen besteht aus 27 Fragen welche die Antworten nie selten manchmal oft immer zulassen Die Antworten werden wie folgt codiert
bull 1 = niebull 2 = seltenbull 3 = manchmalbull 4 = oftbull 5 = immer
Der Fragebogen wird nun von 122 Personen ausgefuumlllt Da dieser Datensatz relativ groszlig ist wird aufeine Darstellung der Tabelle verzichtet Der Code zum Erzeugen des Datensatzes lautet
bsp9 lt- structure(list(Frage1 = c(4 4 5 5 5 1 3 3 3 3 5 55 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 3 3 2 5 45 2 4 3 2 5 5 3 3 3 3 3 3 3 3 33 3 4 4 4 4 4 4 4 4 4 4 4 5 1 1 1 1 1 1 1 1 11 1 2 2 2 2 2 2 2 2 2 2 3 3 3 33 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5) Frage2 = c(3 5 45 4 5 3 3 5 3 5 4 4 4 2 5 5 3 22 2 2 3 2 3 5 4 4 3 3 5 3 5 2 3 3 5 4 3 4 1 44 4 5 2 2 3 2 3 5 5 3 5 3 3 5 43 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 51 1 1 1 1 1 1 1 1 1 1 2 2 2 2 22 2 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 55 5) Frage3 = c(4 4 4 4 3 3 2 2 4 2 53 1 2 3 4 4 3 3 3 4 5 4 5 4 4 3 3 5 5 2 4 43 2 3 4 3 3 3 1 3 3 2 4 1 1 3 3 3 55 4 2 5 4 4 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 44 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 55 5 5 5 5 5 5 5) Frage4 = c(4 3 1 3 3
4 4 3 3 3 5 5 1 3 2 2 4 4 2 2 4 5 4 5 3 4 5 55 3 5 2 5 3 2 3 3 4 3 4 1 2 3 4 52 3 2 3 2 4 5 4 1 4 2 4 2 3 3 3 3 3 3 3 3 3 33 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 33 3 3 3 5 5 5 5 5 5 5 5 5 5)Frage5 = c(5 1 2 5 2 4 4 1 1 4 5 4 3 5 3 5 1 1 45 5 4 2 4 3 1 2 1 3 4 2 1 1 4 1 1
181
Datenbeispiele
2 4 2 3 3 4 4 4 5 2 2 2 3 3 4 2 3 3 4 3 5 2 33 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 22 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 55 5 5 5 5 5 5) Frage6 = c(5 3 1 4 5 5 4 3 3 4 5 5
4 4 3 2 4 5 3 3 3 3 3 4 3 4 5 4 25 5 4 5 4 2 2 5 3 3 3 1 4 4 4 5 3 2 3 1 2 5 43 5 4 3 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 12 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 33 3 3 5 5 5 5 5 5 5 5 5 5) Frage7 = c(3 3 2 4 4 34 3 5 3 4 5 3 4 2 3 4 3 4 3 2 2 2
1 4 4 4 4 3 3 5 5 4 4 4 2 5 3 3 4 2 5 3 3 5 43 5 3 3 4 5 4 3 5 4 4 5 3 3 3 3 33 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 1 1 1 1 11 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 33 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5) Frage8 =c(4 5 5 5 4 5 4 2 5 4 5 5 4 4 4 4 53 3 1 3 4 4 3 3 5 5 5 5 4 5 5 5 3 3 4 5 3 3 42 5 3 4 5 3 3 4 3 4 5 4 4 4 5 4 5
4 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 45 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 22 2 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 55 5) Frage9 = c(5 5 5 5 5 5 5 2 5 3 5 4
4 4 2 4 5 4 2 2 3 4 4 4 3 5 5 5 5 3 4 4 5 4 54 5 4 4 4 2 5 4 4 5 2 3 2 4 2 4 4 45 2 3 5 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 44 4 4 4 4 5 1 1 1 1 1 1 1 1 1 1 1 2 22 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) Frage10 = c(2 1 5 4 3 4 2 45 1 3 2 1 1 1 5 4 2 2 5 3 5 2 2 3 1 1 2 5 5 23 3 4 2 5 4 5 5 3 2 5 4 3 4 2 4 1 43 5 3 3 4 5 3 5 4 3 3 3 3 3 3 3 3 3 3 3 4 4 44 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 55 5 5 5 5 5 5 5 5) Frage11 = c(3 1 5 4
4 3 3 2 1 3 4 4 1 4 4 4 4 1 3 5 5 5 3 5 5 2 52 1 2 5 3 5 5 1 1 2 5 4 4 3 3 4 4 53 3 3 3 3 5 5 5 5 3 3 5 5 3 3 3 3 3 3 3 3 3 33 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 33 3 3 5 5 5 5 5 5 5 5 5 5) Frage12 = c(15 3 2 5 3 2 1 1 2 1 4 3 1 3 1 1 3 3 1 3 1 2 24 4 5 5 3 1 3 1 1 4 2 1 5 4 3 3 2 43 2 5 5 1 1 3 3 4 5 4 4 4 2 5 1 3 3 3 3 3 3 33 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 33 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5)Frage13 = c(2 4 2 3 3 3 3 3 2 2 4 4 1 2 1 2 4 4 23 2 3 3 1 2 3 5 4 4 2 1 3 5 3 4 1 53 3 3 1 2 3 1 4 5 3 1 4 4 2 4 2 2 5 2 3 5 3 33 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 22 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 55 5 5) Frage14 = c(4 3 2 4 4 5 4 3 2 4 5 4 5 3 14 5 5 1 3 2 3 3 5 3 3 5 4 4 3 5 3 5 3
4 3 4 4 4 2 1 4 3 3 4 2 2 5 4 4 1 2 2 3 4 3 35 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 22 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 55 5 5 5 5 5) Frage15 = c(4 3 2 5 4 5 3 2 1 4 5 45 3 3 3 5 5 2 3 4 4 1 2 3 4 5 5 3 5 12 3 3 1 4 5 3 5 2 2 5 4 4 4 5 5 4 3 3 1 5 1 15 2 3 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 22 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 55 5 5 5 5 5 5 5 5) Frage16 = c(3 5 1 5 4 1 3 2 32 5 5 5 4 4 3 4 4 4 4 4 4 3 4 4 4 5 3
182
Beispiel 9
1 2 5 4 3 3 5 4 4 4 5 4 4 3 4 3 4 5 5 5 4 4 55 1 5 5 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 12 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 33 3 5 5 5 5 5 5 5 5 5 5) Frage17 = c(4 4 4 2 3 22 4 5 3 1 4 5 3 2 4 4 4 1 2 4 5 3 4 14 5 3 1 3 3 4 1 5 2 4 3 5 5 4 1 5 3 4 4 5 45 4 4 5 5 3 4 5 4 5 5 3 3 3 3 3 3 3 33 3 3 4 4 4 4 4 4 4 4 4 4 4 5 1 1 1 1 1 1 11 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 33 3 3 3 3 5 5 5 5 5 5 5 5 5 5) Frage18 = c(4 2 15 3 5 2 4 3 4 2 3 1 3 2 2 2 1 1 4 1 52 5 2 1 2 5 3 2 5 4 4 1 3 1 2 5 4 5 3 5 3 3 5
3 5 2 4 5 1 2 1 3 5 2 3 4 3 3 3 3 33 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 1 1 1 1 11 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 33 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5) Frage19 =c(3 1 4 5 4 5 4 2 5 5 5 3 3 5 4 4 1 2 22 1 1 1 1 3 3 4 2 4 1 3 5 5 5 2 4 4 4 3 5 2 43 4 5 3 5 2 3 4 5 5 3 1 5 3 2 5 3 33 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 1 11 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 22 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5)Frage20 = c(4 3 4 3 3 5 4 1 4 3 5 4 4 2 4 25 4 4 1 3 3 2 5 4 5 5 5 5 4 5 4 5 4 2 4 5 2 43 2 4 3 3 5 5 2 3 1 2 2 4 5 5 5 3 35 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 45 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 22 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 55) Frage21 = c(4 2 3 5 3 5 4 3 3 3 5 5 55 4 5 5 3 5 3 3 2 3 4 3 5 5 5 5 5 5 4 4 4 4 44 2 4 3 2 5 3 4 5 3 2 4 4 4 3 5 5 5
4 4 3 5 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 44 4 4 5 1 1 1 1 1 1 1 1 1 1 1 2 2 22 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 55 5 5 5) Frage22 = c(5 3 5 4 3 5 4 1 5 35 4 4 4 3 5 5 3 4 4 3 3 2 3 5 5 5 5 5 4 2 2 55 3 4 4 4 4 3 5 3 3 4 5 5 3 3 5 5 55 3 5 4 4 4 5 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 44 4 4 4 4 4 5 1 1 1 1 1 1 1 1 1 1 12 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 55 5 5 5 5 5 5) Frage23 = c(4 5 4 2 2 4 3
1 5 4 5 4 4 5 5 5 5 4 5 3 2 3 2 4 4 4 4 4 5 45 3 3 4 3 3 1 4 4 3 3 4 4 5 5 4 4 2
4 5 5 5 3 5 5 5 4 4 3 3 3 3 3 3 3 3 3 3 3 4 44 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 35 5 5 5 5 5 5 5 5 5) Frage24 = c(5 4 1 4
4 5 4 3 5 4 4 5 4 4 3 1 4 4 3 2 3 2 2 5 4 5 34 3 5 5 4 4 3 1 5 4 3 2 3 3 4 3 3 3
4 1 4 3 4 5 3 2 5 2 5 4 4 3 3 3 3 3 3 3 3 3 33 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 33 3 3 5 5 5 5 5 5 5 5 5 5) Frage25 = c(33 1 3 4 5 4 3 4 3 4 4 4 5 3 3 4 5 4 1 3 2 31 4 4 5 5 5 4 1 4 2 4 5 4 5 4 2 4 3 43 4 4 5 1 5 2 3 5 5 3 5 3 5 4 4 3 3 3 3 3 33 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 33 3 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 52 2 2 4 5 4 4 3 5 5 5 5 5 3 5 3 5 53 3 3 2 3 3 4 4 5 2 5 3 4 5 4 3 3 4 4 4 5 3 33 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 22 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 55 5 5) Frage27 = c(2 5 2 4 4 4 3 1 3 5 5 5 5 4 34 2 2 3 3 2 2 3 4 3 5 5 4 5 3 1 3 1 2
183
Datenbeispiele
2 4 5 4 4 3 5 4 3 4 5 5 3 5 3 4 5 4 3 5 4 4 55 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 22 2 2 2 3 3 3 3 3 3 3 3 3 3 5 5 5 55 5 5 5 5 5)) Names = c(Frage1 Frage2 Frage3Frage4 Frage5 Frage6 Frage7 Frage8 Frage9Frage10 Frage11 Frage12 Frage13 Frage14 Frage15Frage16 Frage17 Frage18 Frage19 Frage20Frage21 Frage22 Frage23 Frage24 Frage25 Frage26Frage27) rownames = c(NA 122L) class = dataframenaaction = structure(123231 Names = c(38 39 40 4142 43 44 45 46 47 48 49 50 5152 53 54 55 56 57 58 59 60 61 6263 64 65 66 67 68 69 70 71 7273 74 75 76 77 78 79 80 81 82 158159 160 161 162 163 164 165 166167 168 169 170 171 172 173 174 175176 177 178 179 180 181 182 183 184185 186 187 188 189 190 191 192 193194 195 196 197 198 199 200 201202 203 204 205 206 207 208 209 210211 212 213 214 215 216 217 218 219220 221) class = omit))
4810 Beispiel 10
In einer Untersuchung wurde bei Kinder (Self) und deren Eltern (Proxy) bestimmte Werte uumlber dieKinder abgefragt Die Kinder schaumltzten sich also zunaumlchst selber ein anschlieszligend haben die Elternihre Kinder eingeschaumltzt Zusaumltzlich existieren zu jedem Item Normwerte (Norm) die den deutschenDurchschnitt widerspiegeln
bsp10 lt- structure(list(Case = c(1 1 1 1 1 1 22 2 2 2 2 3 3 3 3 3 3 6 66 6 6 6 8 8 8 8 8 8 87 87 8787 87 87 97 97 97 97 97 97 3 3 33 3 3 3 3 3 3 3 3 4 4 4 44 4 5 5 5 5 5 5 6 6 6 6 66 8 8 8 8 8 8 87 87 87 87 8787 97 97 97 97 97 97 Norm Norm NormNorm Norm Norm Norm Norm Norm Norm NormNorm) Item = structure(c(2L 3L 4L 5L 6L 7L 2L 3L 4L 5L6L 7L 2L 3L 4L 5L 6L 7L 2L 3L 4L 5L 6L 7L 2L 3L 4L5L 6L 7L 2L 3L 4L 5L 6L 7L 2L 3L 4L 5L 6L 7L 2L 3L4L 5L 6L 7L 2L 3L 4L 5L 6L 7L 2L 3L 4L 5L 6L 7L 2L3L 4L 5L 6L 7L 2L 3L 4L 5L 6L 7L 2L 3L 4L 5L 6L 7L2L 3L 4L 5L 6L 7L 2L 3L 4L 5L 6L 7L 2L 3L 4L 5L 6L7L 2L 3L 4L 5L 6L 7L) Label = c(Item Body EmotionFamily Friends School Index) class = factor)Score = c(73201612015845 595103286592648 51211152156733578338409160427 628406196084782 598493862271105642956371038732 432100676781528 452472845564316532323487558682 480853674487552 598493862271105470820037411972 50611904867224 383277278491481337624512920086 429406488823006 444784623272101496265680017606 3786511552469 465337891235228578338409160427 348124918251294 422729427242036556028554137324 447951224546969 532511808274062497945287460269 510750344123124 482897549745108642956371038732 465276241871987 49465181672823546928570478635 510750344123124 482897549745108642956371038732 432100676781528 479305655106504
184
Beispiel 10
497945287460269 544010389092698 53107074107393352679424728785 400684105152636 590810578447264928427673577973 412400158442848 402047327317923495401073855047 442682553036083 560092601714117928427673577973 412400158442848 417118474878159 712257238675
630762558775002 491044321652144 596677528939964636827432674325 66246501340745 593808825999571493745883304313 454684267559846 525916164348338554046058734162 526531091581688 436611274898783346555670768689 437937149049355 596677528939964329468364077597 347243154371611 34770256416197400684105152636 534121134505333 341372899040197514234786227506 417118474878159 558940393515167381771760608847 421816928023213 525916164348338476930520805652 387563367324969 495401073855047442682553036083 421816928023213 45940740447710335348549195 387563367324969 7522 8123 7916 78547252 7773 7436 7852 7977 7039 7207 7714) Number= structure(c(1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 2L 2L2L 2L 2L 2L 2L 2L 2L 2L 2L 2L) Label = c(FirstNorm) class = factor) Proxy = structure(c(2L 2L 2L 2L2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L 2L2L 2L 2L 2L 2L 2L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L 1L1L 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 NumberProxy) rownames = 2103 class = dataframe)1gt
185
49 Graphikbeispiele
Die hier verwendeten Grafiken stammen von Benutzer Thire1 und sollen die Themen des KapitelsGNU R Diagramme2 veranschaulichen
491 Graphikbeispiel 1
Abb 8
Quelltext
1 httpdewikipediaorgwikiBenutzer3AThire2FBilder23Mathematische_Grafiken
2 Kapitel 26 auf Seite 75
187
Graphikbeispiele
class=c3(018525303540100)cols=c4(skyblue4darkgreenyelloworangereddarkredblack)gr=seq5(1422length=100)
bmiklt-function6(groessekonstant) return(groesseˆ2konstant)
png7(filename=BodyMassIndexpng width=1024 height=768pointsize=12)par8(bg=whitesmoke)plot9(grbmik(gr18)type=nxlim=c(160199)ylim=c(40125)xaxt=nyaxt=ncexaxis=14cexlab=13cexmain=17xlab=Groumlszlige[in m]ylab=Gewicht [in kg] main=Body Mass Index)polygon10
(c11(grrev12(gr))c(bmik(grclass[1])rev13(bmik(grclass[2])))col=cols[1])polygon
(c(grrev14(gr))c(bmik(grclass[2])rev15(bmik(grclass[3])))col=cols[2])polygon(c(grrev(gr))c(bmik(grclass[3])rev(bmik(grclass[4])))col=cols[3])polygon(c(grrev(gr))c(bmik(grclass[4])rev(bmik(grclass[5])))col=cols[4])polygon(c(grrev(gr))c(bmik(grclass[5])rev(bmik(grclass[6])))col=cols[5])polygon(c(grrev(gr))c(bmik(grclass[6])rev(bmik(grclass[7])))col=cols[6])polygon(c(grrev(gr))c(bmik(grclass[7])rev(bmik(grclass[8])))col=cols[7])
box16()grid17(lty=dotdashcol=darkgrey)abline18
(v=seq(165195by=01)h=seq(50110by=20)lty=dottedcol=grey)
legend19(x=bottomrightinset=0005legend=c(UntergewichtNormalgewichtPraumladipositasAdipositasGrad IAdipositas Grad IIAdipositas GradIII)col=colslwd=6bg=skyblue)axis20(1at=format(seq(1602by=0
1)nsmall=2)labels=format(seq(1602by=01)nsmall=2)cexaxis=15)axis(1at=seq(1652by=01)cexaxis=12colaxis=grey)axis(2at=seq(40120by=10)cexaxis=15)
devoff21()
188
Graphikbeispiel 2
492 Graphikbeispiel 2
Abb 9
Quelltext
parliamentlt-function22(x labels=names(x) edges=5000col=rainbow(length(x)) radin=025 )
plot23(c24(-11) c(01) type=n axes=FALSE xlab= ylab= )y=c(0picumsum(x)sum(x))ang=seq25(0pilength=edges)for (aktiv in 1(length(y)-1))
poly=ang[ y[aktiv]lt=ang amp anglt=y[aktiv+1] ]polygon26(c(cos(poly)0)
c(sin(poly)0)col=col[aktiv]border=col[aktiv])text27( (cos28(y[ak
tiv])+cos(y[aktiv+1])+radincos(y[aktiv])+radincos(y[aktiv+1]))4(sin(y[aktiv])+sin(y[aktiv+1])+radinsin(y[aktiv])+radinsin(y[aktiv+1]))4col=white labels=paste(labels[aktiv] n x[aktiv]) cex=12adj=c(0505))
polygon29(radincos(ang)radinsin(ang)col=par(bg)border=par(bg))
xlt-c(216676821)names30(x)lt-c(FPOuml OumlVP BZOuml SPOuml Gruumlne)
png31(filename=Mandate2006png width=1300 height=850 pointsize=12)par32(bg=whitesmoke)parliament(x col=c(126ca8 black ec921a red61bb46) main=Nationalratswahl 2006 - Mandatsverteilung
189
Graphikbeispiele
cexmain=17)devoff33()
493 Graphikbeispiel 3
Abb 10
Quelltext
qs=c(00507509095099)cs=heatcolors(length(qs))
qplotlt-function34(qsxpdfcdfpfl) plot35(xpdftype=nylim=range(pdf0)125xlab=ylab=)for (q in 1(length36(qs)-1)) xd= x[(cdfgt=qs[q])amp(cdflt=qs[q+1])]yd= pdf[(cdfgt=qs[q])amp(cdflt=qs[q+1])]polygon37(c(xdxd[length(xd)]xd[1])c(yd00)col=cs[q]border=cs[q])lines38(c(xd[length(xd)]xd
[length(xd)])c(max(pdf)11-001max(pdf)11+001)col=cs[q]lwd=3)arrows39(xd[length
(xd)]-pflmax(pdf)11xd[length(xd)]max(pdf)11lwd=2length=015)text40(xd[length(xd)]max(pdf)115paste(q(format(qs[q+1]100)
)=format(xd[length(xd)]digits=1nsmall=1decimalmark=)sep=)col=cs[q]cex=15adj=c(10))
190
Graphikbeispiel 4
png41(filename = Quantile_graphpng width=1500 height=1000pointsize=12)par42(mfrow=c(21)bg=whitesmoke)
normalverteilungx=seq(-0623by=00001)pdf=dnorm43(x=x)cdf=pnorm44(q=x)
qplot(qsxpdfcdf035)title45(main=Quantile der Normalverteilung)
chi-quadrat verteilungdf=3x=seq46(0113length=10000)pdf=dchisq47(x=xdf=df)cdf=pchisq48(q=xdf=df)
qplot(qsxpdfcdf13)title49(main=Quantile der chi-Quadrat Verteilung)devoff50()
494 Graphikbeispiel 4
Abb 11
Quelltext
value at risk graph
quant=010
191
Graphikbeispiele
min=-17max=26mean=21s=seq51(minmaxlength=10000)d=dnorm52(smean=mean)q=qnorm53(quantmean=mean)sq=c54(s[sltq]qmin)dq=c(d[sltq]00)
png55(filename = VaR_graphpng width=1300 height=800 pointsize=12)par56(bg=whitesmoke)plot57(sdtype=nxlab=Portfoliowert [in MioEUR]ylab=Wahrscheinlichkeitmain=Value atRiskxlim=range(s)0935)abline58(h=0col=grey)polygon59(x=c(smaxmin)y=c(d00)col=snow3)
polygon60(x=sqy=dqcol=skyblue)
text61(x=(q-min)093+miny=dnorm(qmean=mean)03label=paste(format(100quant)sep=)col=bluecex=17)
lines62(x=c(qq)y=c(0dnorm(qmean=mean)135)col=redlwd=3)text63(x=
(q-min)09+miny=dnorm(qmean=mean)14label=paste(VaR=format(qdigits=2) Mio EURsep=)col=redcex=16)
lines64(x=c(meanmean)09y=c(0dnorm(meanmean=mean)095)col=darkgreylwd=2)text65(x=mean087y=dnorm(mean09mean=mean)066label=paste(Portfoliowertheute mean09 Mio EURsep=)col=blacksrt=90)
devoff66()
192
Graphikbeispiel 5
495 Graphikbeispiel 5
Abb 12
Verwendet werden die Daten aus Beispiel 1067
Der Befehl zum Erzeugen der Grafik lautet
library68(lattice) Laumldt das lattice-Grafikpaket
colors lt- c(skyblue4 blue darkgreen61bb46) Farbenfuumlr Werte und Labels
67 Kapitel 4810 auf Seite 184
193
Graphikbeispiele
keylist lt- list(space = right Legende Ausrichtungtitle=Assessed cextitle=12 Legendenuumlberschrift und
Groumlszligepoints=list(pch=c(01538) col=colors cex=1)
Legendensymboletext=list(levels(bsp10$Proxy) cex=1 font=1) Legende
mit Schriftgroumlszlige und -artcol=colors) LegendenSchriftfarbe
grafik lt- dotplot69(Item ˜ Score | Case groups=Proxy data=bsp10layout = c(34) Diagramme werden in 3 Spalten und 4 Reihen
aufgeteiltkey = keylist Verwende die Daten aus dem Objekt
keylistxlab = list(label=Score (T-Rasch) cex=15 font=2)
Label fuumlr X-Achse Schriftgroumlszlige fettylab = list(label=Dimensions cex=15 font=2)
Label fuumlr Y-Achse Schriftgroumlszlige fettmain= list(label=Each kid first measure self and proxy
cex=25) Uumlberschriftsub = list(label=Kinder alle Erst- und Zweiterhebungen
cex=1 font=3)scales = list(cex=12 ces=2) Achsenbeschriftung
(Schriftgroumlszlige)between = list(x=05 y=05) Abstand zwischen den
Diagrammencex = 1 Groumlszlige der Symbolepch=c(01538) col=colors) Symbolart der Werte und
deren Farbeupdate70(grafik
panel = function()panelgrid(h=-1v=-20) Gitterhinzufuumlgen
paneldotplot() )
rm71(colorskeylistgrafik)
194
50 siehe auch
bull Programmierbeispiele1
1 Kapitel 54 auf Seite 233
195
51 Befehle-Index
Auf dieser Seite sollen alle R-Befehle alphabetisch gesammelt werden
511 A
A1 - B2 - C3 - D4 - E5 - F6 - G7 - H8 - I9 - J10 - K11 - L12 - M13 - N14 - O15 - P16 - Q17 - R18 - S19 -T20 - U21 - V22 - W23 - X24 - Y25 - Z26
Befehl Kurzbeschreibungacf(x)27 acf(x) errechnet die Autokorrelation der Daten mit
verschiedenen Intervallen und erstellt eine entsprechendeGrafik
all(x)28 all(x) fragt ab ob das Objekt x nur den WahrheitswertTRUE enthaumllt
any(x)29 any(x) fragt ab ob das Objekt x mindestens einmal denWahrheitswert TRUE enthaumllt
1 Kapitel 511 auf Seite 1972 Kapitel 512 auf Seite 1983 Kapitel 513 auf Seite 1994 Kapitel 514 auf Seite 2015 Kapitel 515 auf Seite 2026 Kapitel 516 auf Seite 2037 Kapitel 517 auf Seite 2048 Kapitel 518 auf Seite 2059 Kapitel 519 auf Seite 20610 Kapitel 5110 auf Seite 20811 Kapitel 5111 auf Seite 20912 Kapitel 5112 auf Seite 21013 Kapitel 5113 auf Seite 21114 Kapitel 5114 auf Seite 21315 Kapitel 5115 auf Seite 21416 Kapitel 5116 auf Seite 21517 Kapitel 5117 auf Seite 21718 Kapitel 5118 auf Seite 21819 Kapitel 5119 auf Seite 21920 Kapitel 5120 auf Seite 22221 Kapitel 5121 auf Seite 22322 Kapitel 5122 auf Seite 22423 Kapitel 5123 auf Seite 22524 Kapitel 5124 auf Seite 22625 Kapitel 5125 auf Seite 22726 Kapitel 5126 auf Seite 22827 httpdewikibooksorgwikiGNU20R3A20acf28 httpdewikibooksorgwikiGNU20R3A20all29 httpdewikibooksorgwikiGNU20R3A20any
197
Befehle-Index
apply(x)30 apply(xcolfunc) wendet auf die Spalten coleines Arrays x die Funktion func an
apropos()31 apropos() sucht einen Ausdruck in der Liste der Funk-tionen und Vektorvariablen
asfactor(x)32 asfactor(x) wandelt das Objekt x in einen Faktorum
asmatrix(x)33 asmatrix(x) wandelt das Objekt x in eine Matrixum Parametrische Schaumltzungen benoumltigen zur weiterenBerechnung eine Matrix
attach(x)34 attach(x) nimmt das Objekt x in den Suchpfad aufavailablepackages()35 availablepackages() zeigt alle verfuumlgbaren Zu-
satzpakete (eines Servers) an
512 B
A36 - B37 - C38 - D39 - E40 - F41 - G42 - H43 - I44 - J45 - K46 - L47 - M48 - N49 - O50 - P51 - Q52 - R53 -S54 - T55 - U56 - V57 - W58 - X59 - Y60 - Z61
Befehl Kurzbeschreibung
30 httpdewikibooksorgwikiGNU20R3A20apply31 httpdewikibooksorgwikiGNU20R3A20apropos32 httpdewikibooksorgwikiGNU20R3A20asfactor33 httpdewikibooksorgwikiGNU20R3A20asmatrix34 httpdewikibooksorgwikiGNU20R3A20attach35 httpdewikibooksorgwikiGNU20R3A20availablepackages36 Kapitel 511 auf Seite 19737 Kapitel 512 auf Seite 19838 Kapitel 513 auf Seite 19939 Kapitel 514 auf Seite 20140 Kapitel 515 auf Seite 20241 Kapitel 516 auf Seite 20342 Kapitel 517 auf Seite 20443 Kapitel 518 auf Seite 20544 Kapitel 519 auf Seite 20645 Kapitel 5110 auf Seite 20846 Kapitel 5111 auf Seite 20947 Kapitel 5112 auf Seite 21048 Kapitel 5113 auf Seite 21149 Kapitel 5114 auf Seite 21350 Kapitel 5115 auf Seite 21451 Kapitel 5116 auf Seite 21552 Kapitel 5117 auf Seite 21753 Kapitel 5118 auf Seite 21854 Kapitel 5119 auf Seite 21955 Kapitel 5120 auf Seite 22256 Kapitel 5121 auf Seite 22357 Kapitel 5122 auf Seite 22458 Kapitel 5123 auf Seite 22559 Kapitel 5124 auf Seite 22660 Kapitel 5125 auf Seite 22761 Kapitel 5126 auf Seite 228
198
C
barplot()62 barplot() erstellt Saumlulendiagrammeblockrand()63 blockrand() (aus dem gleichnamigen Zusatzpaket) erzeugt Block-
Randomisierungen fuumlr Clinical Trialsboxplot()64 boxplot() erstellt ein Boxplot der Daten
513 C
A65 - B66 - C67 - D68 - E69 - F70 - G71 - H72 - I73 - J74 - K75 - L76 - M77 - N78 - O79 - P80 - Q81 - R82 -S83 - T84 - U85 - V86 - W87 - X88 - Y89 - Z90
Befehl Kurzbeschreibungc91 concatenate (abgekuumlrzt mit c) bedeutet aneinanderhaumln-
gen So lassen sich Zahlen- oder Buchstabenreihen einemVektor zuordnen zBmeinvector lt- c(2456)
cat()92 mit cat(abc) werden die Elemente a b und c zusam-mengefuumlhrt und in Zeichenketten konvertiert
62 httpdewikibooksorgwikiGNU20R3A20barplot63 httpdewikibooksorgwikiGNU20R3A20blockrand64 httpdewikibooksorgwikiGNU20R3A20boxplot65 Kapitel 511 auf Seite 19766 Kapitel 512 auf Seite 19867 Kapitel 513 auf Seite 19968 Kapitel 514 auf Seite 20169 Kapitel 515 auf Seite 20270 Kapitel 516 auf Seite 20371 Kapitel 517 auf Seite 20472 Kapitel 518 auf Seite 20573 Kapitel 519 auf Seite 20674 Kapitel 5110 auf Seite 20875 Kapitel 5111 auf Seite 20976 Kapitel 5112 auf Seite 21077 Kapitel 5113 auf Seite 21178 Kapitel 5114 auf Seite 21379 Kapitel 5115 auf Seite 21480 Kapitel 5116 auf Seite 21581 Kapitel 5117 auf Seite 21782 Kapitel 5118 auf Seite 21883 Kapitel 5119 auf Seite 21984 Kapitel 5120 auf Seite 22285 Kapitel 5121 auf Seite 22386 Kapitel 5122 auf Seite 22487 Kapitel 5123 auf Seite 22588 Kapitel 5124 auf Seite 22689 Kapitel 5125 auf Seite 22790 Kapitel 5126 auf Seite 22891 httpdewikibooksorgwikiGNU20R3A20c92 httpdewikibooksorgwikiGNU20R3A20cat
199
Befehle-Index
cbind()93 mit cbind(abc) lassen sich die Vektoren a b und cspaltenweise zu einer Matrix zusammenfuumlhren (siehe auchrbind()94)
ceiling(x)95 ceiling(x) rundet alle Werte im Objekt x auf ganze Zah-len auf (siehe auch floor()96 zum abrunden)
chisqtest(x)97 chisqtest(x) fuumlhrt den Chi-Quadrat-Test auf das Ob-jekt x aus
chooseCRANmirror()98 Mit chooseCRANmirror() wird ein CRAN-Mirror fuumlrdie bestehende Session ausgewaumlhlt
class()99 class()colnames()100 colnames() weist den Spalten einer Matrix einen Na-
men (Label) zu Siehe rownames()101 fuumlr Reihen)colors()102 colors() zeigt eine Uumlbersicht aller Farben an die derzeit
verfuumlgbar sindcomment()103 comment() weist einem Objekt einen Kommentar (Label)
zucor(ab)104 cor(ab) errechnet Korrelationkoeffizienten zwischen a
und bcortest(ab)105 cortest(ab) errechnet Korrelationkoeffizienten samt
Signifikanzniveau und Konfidenzintervallen
93 httpdewikibooksorgwikiGNU20R3A20cbind94 Kapitel 5118 auf Seite 21895 httpdewikibooksorgwikiGNU20R3A20ceiling96 httpdewikibooksorgwikiGNU20R3A20floor97 httpdewikibooksorgwikiGNU20R3A20chisqtest98 httpdewikibooksorgwikiGNU20R3A20chooseCRANmirror99 httpdewikibooksorgwikiGNU20R3A20class100 httpdewikibooksorgwikiGNU20R3A20colnames101 httpdewikibooksorgwikiGNU20R3A20rownames102 httpdewikibooksorgwikiGNU20R3A20colors103 httpdewikibooksorgwikiGNU20R3A20comment104 httpdewikibooksorgwikiGNU20R3A20cor105 httpdewikibooksorgwikiGNU20R3A20cortest
200
D
514 D
A106 - B107 - C108 - D109 - E110 - F111 - G112 - H113 - I114 - J115 - K116 - L117 - M118 - N119 - O120 -P121 - Q122 - R123 - S124 - T125 - U126 - V127 - W128 - X129 - Y130 - Z131
Befehl Kurzbeschreibungdata()132 data() aktiviert einen Datensatz (zB aus einem Zusatzpa-
ket) bzw listet verfuumlgbare Datensaumltze aufdataentry(x)133 dataentry(x) oumlffnet den Daten-Editor und ermoumlglicht so
die Bearbeitung der Daten (hinzufuumlgenloumlscheneditieren) desObjekts x
dataframe(abc)134 dataframe(abc) fuumlhrt die Objekte a b c zu ei-nem Datenframe zusammen
deparse(x)135 deparse(x) gibt einen dem Ausdruck oder Objekt x ent-sprechenden String zuruumlck Damit lassen sich zB die internenRepraumlsentationen von Datenobjekten ausgeben und bearbei-tenweiterverwenden
detach(x)136 detach(x) loumlscht das Datenframe x aus dem Suchpfad bzwdeaktiviert eingebundene Zusatzpakete
devSVG()137 devSVG() speichert eine Grafik als SVG-Datei ab Dazu istjedoch das Zusatzpaket RSvgDevice erforderlich
106 Kapitel 511 auf Seite 197107 Kapitel 512 auf Seite 198108 Kapitel 513 auf Seite 199109 Kapitel 514 auf Seite 201110 Kapitel 515 auf Seite 202111 Kapitel 516 auf Seite 203112 Kapitel 517 auf Seite 204113 Kapitel 518 auf Seite 205114 Kapitel 519 auf Seite 206115 Kapitel 5110 auf Seite 208116 Kapitel 5111 auf Seite 209117 Kapitel 5112 auf Seite 210118 Kapitel 5113 auf Seite 211119 Kapitel 5114 auf Seite 213120 Kapitel 5115 auf Seite 214121 Kapitel 5116 auf Seite 215122 Kapitel 5117 auf Seite 217123 Kapitel 5118 auf Seite 218124 Kapitel 5119 auf Seite 219125 Kapitel 5120 auf Seite 222126 Kapitel 5121 auf Seite 223127 Kapitel 5122 auf Seite 224128 Kapitel 5123 auf Seite 225129 Kapitel 5124 auf Seite 226130 Kapitel 5125 auf Seite 227131 Kapitel 5126 auf Seite 228132 httpdewikibooksorgwikiGNU20R3A20data133 httpdewikibooksorgwikiGNU20R3A20dataentry134 httpdewikibooksorgwikiGNU20R3A20dataframe135 httpdewikibooksorgwikiGNU20R3A20deparse136 httpdewikibooksorgwikiGNU20R3A20detach137 httpdewikibooksorgwikiGNU_R3A20devSVG
201
Befehle-Index
dim(x)138 Mit dim(x) wird die Anzahl der Dimensionen (Anzahl derSpalten und Anzahl der Zeilen) der Matrix x ermittelt
dimnames(x)139 Mit dimnames(x) werden den Dimensionen (SpaltenZei-len) der Matrix x Namen (Labels) zugeordnet
dir()140 dir() ist ein Alias zu listfiles() und zeigt die Datei-en des aktuellen Arbeitsverzeichnises an
dotchart(x)141 dotchart(x) erstellt Punktediagrammeduplicated(data)142 duplicated(data) uumlberpruumlft den Datensatz data auf
doppelte bzw mehrfach eingetragene Faumllle (Duplikate) undgibt TRUEFALSE-Werte fuumlr jeden Eintrag zuruumlck (siehe auchunique()143)
515 E
A144 - B145 - C146 - D147 - E148 - F149 - G150 - H151 - I152 - J153 - K154 - L155 - M156 - N157 - O158 -P159 - Q160 - R161 - S162 - T163 - U164 - V165 - W166 - X167 - Y168 - Z169
Befehl Kurzbeschreibung
138 httpdewikibooksorgwikiGNU20R3A20dim139 httpdewikibooksorgwikiGNU20R3A20dimnames140 httpdewikibooksorgwikiGNU20R3A20dir141 httpdewikibooksorgwikiGNU20R3A20dotchart142 httpdewikibooksorgwikiGNU20R3A20duplicated143 httpdewikibooksorgwikiGNU20R3A20unique144 Kapitel 511 auf Seite 197145 Kapitel 512 auf Seite 198146 Kapitel 513 auf Seite 199147 Kapitel 514 auf Seite 201148 Kapitel 515 auf Seite 202149 Kapitel 516 auf Seite 203150 Kapitel 517 auf Seite 204151 Kapitel 518 auf Seite 205152 Kapitel 519 auf Seite 206153 Kapitel 5110 auf Seite 208154 Kapitel 5111 auf Seite 209155 Kapitel 5112 auf Seite 210156 Kapitel 5113 auf Seite 211157 Kapitel 5114 auf Seite 213158 Kapitel 5115 auf Seite 214159 Kapitel 5116 auf Seite 215160 Kapitel 5117 auf Seite 217161 Kapitel 5118 auf Seite 218162 Kapitel 5119 auf Seite 219163 Kapitel 5120 auf Seite 222164 Kapitel 5121 auf Seite 223165 Kapitel 5122 auf Seite 224166 Kapitel 5123 auf Seite 225167 Kapitel 5124 auf Seite 226168 Kapitel 5125 auf Seite 227169 Kapitel 5126 auf Seite 228
202
F
edit(x)170 edit(x) ruft das Objekt x in einem externen Editor zur Bearbeitung auf(siehe auch fix(x)171)
exp(x)172 exp(x) gibt die Exponentinalfunktion fuumlr die in x enthaltenen Werte
516 F
A173 - B174 - C175 - D176 - E177 - F178 - G179 - H180 - I181 - J182 - K183 - L184 - M185 - N186 - O187 -P188 - Q189 - R190 - S191 - T192 - U193 - V194 - W195 - X196 - Y197 - Z198
Befehl Kurzbeschreibungfactanal(x)199 factanal(x) fuumlhrt eine Haupt- und Maximum-Likelihood-
Faktorenanalyse auf das Objekt x durch (siehe auchprincomp(x)200)
factor()201 factor() erzeugt ein Faktor-Objektfishertest(x)202 fishertest(x) fuumlhrt den exaten Test nach Fisher fuumlr das
Objekt x durch
170 httpdewikibooksorgwikiGNU20R3A20edit171 httpdewikibooksorgwikiGNU20R3A20fix172 httpdewikibooksorgwikiGNU20R3A20exp173 Kapitel 511 auf Seite 197174 Kapitel 512 auf Seite 198175 Kapitel 513 auf Seite 199176 Kapitel 514 auf Seite 201177 Kapitel 515 auf Seite 202178 Kapitel 516 auf Seite 203179 Kapitel 517 auf Seite 204180 Kapitel 518 auf Seite 205181 Kapitel 519 auf Seite 206182 Kapitel 5110 auf Seite 208183 Kapitel 5111 auf Seite 209184 Kapitel 5112 auf Seite 210185 Kapitel 5113 auf Seite 211186 Kapitel 5114 auf Seite 213187 Kapitel 5115 auf Seite 214188 Kapitel 5116 auf Seite 215189 Kapitel 5117 auf Seite 217190 Kapitel 5118 auf Seite 218191 Kapitel 5119 auf Seite 219192 Kapitel 5120 auf Seite 222193 Kapitel 5121 auf Seite 223194 Kapitel 5122 auf Seite 224195 Kapitel 5123 auf Seite 225196 Kapitel 5124 auf Seite 226197 Kapitel 5125 auf Seite 227198 Kapitel 5126 auf Seite 228199 httpdewikibooksorgwikiGNU20R3A20factanal200 httpdewikibooksorgwikiGNU20R3A20princomp201 httpdewikibooksorgwikiGNU20R3A20factor202 httpdewikibooksorgwikiGNU20R3A20fishertest
203
Befehle-Index
fix(x)203 fix(x) ruft das Objekt x in einem graphischen Editor auf Solassen sich Daten korregieren editieren und erweitern (siehe auchedit(x)204 fuumlr externen Editor)
floor(x)205 floor(x) rundet alle Werte im Objekt x auf ganze Zahlen ab(siehe auch ceiling(x)206 zum aufrunden)
forestplot207 forestplot (aus dem Zusatzpaket rmeta) erzeugt ein so ge-nanntes Forest Plot zusammen mit einer Texttabelle (siehe auchmetaplot208)
517 G
A209 - B210 - C211 - D212 - E213 - F214 - G215 - H216 - I217 - J218 - K219 - L220 - M221 - N222 - O223 -P224 - Q225 - R226 - S227 - T228 - U229 - V230 - W231 - X232 - Y233 - Z234
Befehl Kurzbeschreibunggcd(xy)235 gcd(xy) (aus dem schoolmath-Paket) berechnet den groumlszligten
gemeinsamen Teiler der Zahlen x und y
203 httpdewikibooksorgwikiGNU20R3A20fix204 httpdewikibooksorgwikiGNU20R3A20edit205 httpdewikibooksorgwikiGNU20R3A20floor206 httpdewikibooksorgwikiGNU20R3A20ceiling207 httpdewikibooksorgwikiGNU_R3A20forestplot208 httpdewikibooksorgwikiGNU_R3A20metaplot209 Kapitel 511 auf Seite 197210 Kapitel 512 auf Seite 198211 Kapitel 513 auf Seite 199212 Kapitel 514 auf Seite 201213 Kapitel 515 auf Seite 202214 Kapitel 516 auf Seite 203215 Kapitel 517 auf Seite 204216 Kapitel 518 auf Seite 205217 Kapitel 519 auf Seite 206218 Kapitel 5110 auf Seite 208219 Kapitel 5111 auf Seite 209220 Kapitel 5112 auf Seite 210221 Kapitel 5113 auf Seite 211222 Kapitel 5114 auf Seite 213223 Kapitel 5115 auf Seite 214224 Kapitel 5116 auf Seite 215225 Kapitel 5117 auf Seite 217226 Kapitel 5118 auf Seite 218227 Kapitel 5119 auf Seite 219228 Kapitel 5120 auf Seite 222229 Kapitel 5121 auf Seite 223230 Kapitel 5122 auf Seite 224231 Kapitel 5123 auf Seite 225232 Kapitel 5124 auf Seite 226233 Kapitel 5125 auf Seite 227234 Kapitel 5126 auf Seite 228235 httpdewikibooksorgwikiGNU20R3A20gcd
204
H
getwd()236 getwd() gibt das aktuelle Arbeitsverzeichnis ausggplot()237 ggplot() aus dem Paket ggplot2 stellt eine Alternative zur
Standard-plot()-Funktion darglm()238 glm() ist die Hauptfunktion fuumlr generalized linear models (inkl
logistische Regressionsanalyse)graphicsoff()239 Mit graphicsoff() werden alle Graphikfenster geschlossengrep(TEXT x)240 grep(TEXT x) untersucht ob der Text TEXT im Objekt x
enthalten istgsub241 Mit gsub(MusterErsetzungObjekt) lassen sich
Zeichenketten (mehrfach) in einem Objekt ersetzen
518 H
A242 - B243 - C244 - D245 - E246 - F247 - G248 - H249 - I250 - J251 - K252 - L253 - M254 - N255 - O256 -P257 - Q258 - R259 - S260 - T261 - U262 - V263 - W264 - X265 - Y266 - Z267
Befehl Kurzbeschreibung
236 httpdewikibooksorgwikiGNU20R3A20getwd237 httpdewikibooksorgwikiGNU20R3A20ggplot238 httpdewikibooksorgwikiGNU20R3A20glm239 httpdewikibooksorgwikiGNU20R3A20graphicsoff240 httpdewikibooksorgwikiGNU20R3A20grep241 httpdewikibooksorgwikiGNU20R3A20sub242 Kapitel 511 auf Seite 197243 Kapitel 512 auf Seite 198244 Kapitel 513 auf Seite 199245 Kapitel 514 auf Seite 201246 Kapitel 515 auf Seite 202247 Kapitel 516 auf Seite 203248 Kapitel 517 auf Seite 204249 Kapitel 518 auf Seite 205250 Kapitel 519 auf Seite 206251 Kapitel 5110 auf Seite 208252 Kapitel 5111 auf Seite 209253 Kapitel 5112 auf Seite 210254 Kapitel 5113 auf Seite 211255 Kapitel 5114 auf Seite 213256 Kapitel 5115 auf Seite 214257 Kapitel 5116 auf Seite 215258 Kapitel 5117 auf Seite 217259 Kapitel 5118 auf Seite 218260 Kapitel 5119 auf Seite 219261 Kapitel 5120 auf Seite 222262 Kapitel 5121 auf Seite 223263 Kapitel 5122 auf Seite 224264 Kapitel 5123 auf Seite 225265 Kapitel 5124 auf Seite 226266 Kapitel 5125 auf Seite 227267 Kapitel 5126 auf Seite 228
205
Befehle-Index
head()268 Mit dem Befehl head(DATA n) lassen sich die ersten n Datenrei-hen des Datensatzes DATA anzeigen Der Befehl tail()269 lieferthingegen die letzten n Datenreihen
help()270 271 help() bzw zeigt die R-interne Dokumentation zu einem Befehlan
helpstart()272 helpstart() oumlffnet den Standardbrowser mit den Links zu denR-Manualen
hist()273 hist() erstellt ein Histogramm der Datenhistory()274 history() gibt die letzten Befehle in ein separates Fenster aus
519 I
A275 - B276 - C277 - D278 - E279 - F280 - G281 - H282 - I283 - J284 - K285 - L286 - M287 - N288 - O289 -P290 - Q291 - R292 - S293 - T294 - U295 - V296 - W297 - X298 - Y299 - Z300
Befehl Kurzbeschreibung
268 httpdewikibooksorgwikiGNU20R3A20head269 httpdewikibooksorgwikiGNU20R3A20tail270 httpdewikibooksorgwikiGNU20R3A20help271 httpdewikibooksorgwikiGNU20R3A20help272 httpdewikibooksorgwikiGNU20R3A20helpstart273 httpdewikibooksorgwikiGNU20R3A20hist274 httpdewikibooksorgwikiGNU20R3A20history275 Kapitel 511 auf Seite 197276 Kapitel 512 auf Seite 198277 Kapitel 513 auf Seite 199278 Kapitel 514 auf Seite 201279 Kapitel 515 auf Seite 202280 Kapitel 516 auf Seite 203281 Kapitel 517 auf Seite 204282 Kapitel 518 auf Seite 205283 Kapitel 519 auf Seite 206284 Kapitel 5110 auf Seite 208285 Kapitel 5111 auf Seite 209286 Kapitel 5112 auf Seite 210287 Kapitel 5113 auf Seite 211288 Kapitel 5114 auf Seite 213289 Kapitel 5115 auf Seite 214290 Kapitel 5116 auf Seite 215291 Kapitel 5117 auf Seite 217292 Kapitel 5118 auf Seite 218293 Kapitel 5119 auf Seite 219294 Kapitel 5120 auf Seite 222295 Kapitel 5121 auf Seite 223296 Kapitel 5122 auf Seite 224297 Kapitel 5123 auf Seite 225298 Kapitel 5124 auf Seite 226299 Kapitel 5125 auf Seite 227300 Kapitel 5126 auf Seite 228
206
I
identical(x y)301 identical(x y) uumlberpruumlft ob die Objek-te x und y identisch sind Als Antwort wirdTRUEFALSE augegeben
installpackages(mypkg)302 installpackages(mypkg) installiert das Zu-satzpaket mypkg
intersect(x y)303 intersect(x y) gibt die gemeinsamen Elemen-te (Schnittmenge) beider Vektoren x und y als neuenVektor aus
ischaracter(x)304 ischaracter(x) uumlberpruumlft ob das Ob-jekt x vom Typ character ist Als Antwort wirdTRUEFALSE ausgegeben
iselement(x y)305 iselement(x y) uumlberpruumlft ob das Objekt x imObjekt y enthalten ist
isfactor(x)306 isfactor(x) uumlberpruumlft ob das Objekt x vomTyp factor ist Als Antwort wird TRUEFALSE ausge-geben
islogical(x)307 islogical(x) fragt die logical-Eigenschaft desObjekts x ab Als Antwort wird TRUEFALSE ausge-geben
ismatrix(x)308 ismatrix(x) uumlberpruumlft ob das Objekt x eine Ma-trix ist Als Antwort wird TRUEFALSE ausgegeben
isna(x)309 isna(x) uumlberpruumlft ob ein Objekt x ein ElementNA ist Als Antwort wird TRUEFALSE ausgegeben
isnumeric(x)310 isnumeric(x) uumlberpruumlft ob das Objekt x nume-risch ist Als Antwort wird TRUEFALSE ausgege-ben
isprim(x)311 isprim(x) (aus dem schoolmath-Paket) uumlber-pruumlft ob die Zahl x eine Primzahl ist
isvector(x)312 isvector(x) uumlberpruumlft ob das Objekt x ein Vec-tor ist Als Antwort wird TRUEFALSE ausgegeben
ISOdate()313 ISOdate(JahrMonatTagStundeMinuteSekunde)kann zur einfachen Definition eines Datum-Objektsverwendet werden
301 httpdewikibooksorgwikiGNU20R3A20identical302 httpdewikibooksorgwikiGNU20R3A20installpackages303 httpdewikibooksorgwikiGNU20R3A20intersect304 httpdewikibooksorgwikiGNU20R3A20ischaracter305 httpdewikibooksorgwikiGNU20R3A20iselement306 httpdewikibooksorgwikiGNU20R3A20isfactor307 httpdewikibooksorgwikiGNU20R3A20islogical308 httpdewikibooksorgwikiGNU20R3A20ismatrix309 httpdewikibooksorgwikiGNU20R3A20isna310 httpdewikibooksorgwikiGNU20R3A20isnumeric311 httpdewikibooksorgwikiGNU20R3A20isprim312 httpdewikibooksorgwikiGNU20R3A20isvector313 httpdewikibooksorgwikiGNU20R3A20ISOdate
207
Befehle-Index
5110 J
A314 - B315 - C316 - D317 - E318 - F319 - G320 - H321 - I322 - J323 - K324 - L325 - M326 - N327 - O328 -P329 - Q330 - R331 - S332 - T333 - U334 - V335 - W336 - X337 - Y338 - Z339
Befehl Kurzbeschreibungjpeg()340 Mit Hilfe von jpeg() koumlnnen Graphiken in eine jpeg-Datei gespeichert
werden Fuumlr das png-Format steht der Befehl png()341 zur Verfuumlgung
314 Kapitel 511 auf Seite 197315 Kapitel 512 auf Seite 198316 Kapitel 513 auf Seite 199317 Kapitel 514 auf Seite 201318 Kapitel 515 auf Seite 202319 Kapitel 516 auf Seite 203320 Kapitel 517 auf Seite 204321 Kapitel 518 auf Seite 205322 Kapitel 519 auf Seite 206323 Kapitel 5110 auf Seite 208324 Kapitel 5111 auf Seite 209325 Kapitel 5112 auf Seite 210326 Kapitel 5113 auf Seite 211327 Kapitel 5114 auf Seite 213328 Kapitel 5115 auf Seite 214329 Kapitel 5116 auf Seite 215330 Kapitel 5117 auf Seite 217331 Kapitel 5118 auf Seite 218332 Kapitel 5119 auf Seite 219333 Kapitel 5120 auf Seite 222334 Kapitel 5121 auf Seite 223335 Kapitel 5122 auf Seite 224336 Kapitel 5123 auf Seite 225337 Kapitel 5124 auf Seite 226338 Kapitel 5125 auf Seite 227339 Kapitel 5126 auf Seite 228340 httpdewikibooksorgwikiGNU20R3A20jpeg341 httpdewikibooksorgwikiGNU20R3A20png
208
K
5111 K
A342 - B343 - C344 - D345 - E346 - F347 - G348 - H349 - I350 - J351 - K352 - L353 - M354 - N355 - O356 -P357 - Q358 - R359 - S360 - T361 - U362 - V363 - W364 - X365 - Y366 - Z367
Befehl Kurzbeschreibungkstest()368 kstest() fuumlhrt den Kolmogorov-Smirnov-Test durch
342 Kapitel 511 auf Seite 197343 Kapitel 512 auf Seite 198344 Kapitel 513 auf Seite 199345 Kapitel 514 auf Seite 201346 Kapitel 515 auf Seite 202347 Kapitel 516 auf Seite 203348 Kapitel 517 auf Seite 204349 Kapitel 518 auf Seite 205350 Kapitel 519 auf Seite 206351 Kapitel 5110 auf Seite 208352 Kapitel 5111 auf Seite 209353 Kapitel 5112 auf Seite 210354 Kapitel 5113 auf Seite 211355 Kapitel 5114 auf Seite 213356 Kapitel 5115 auf Seite 214357 Kapitel 5116 auf Seite 215358 Kapitel 5117 auf Seite 217359 Kapitel 5118 auf Seite 218360 Kapitel 5119 auf Seite 219361 Kapitel 5120 auf Seite 222362 Kapitel 5121 auf Seite 223363 Kapitel 5122 auf Seite 224364 Kapitel 5123 auf Seite 225365 Kapitel 5124 auf Seite 226366 Kapitel 5125 auf Seite 227367 Kapitel 5126 auf Seite 228368 httpdewikibooksorgwikiGNU20R3A20kstest
209
Befehle-Index
5112 L
A369 - B370 - C371 - D372 - E373 - F374 - G375 - H376 - I377 - J378 - K379 - L380 - M381 - N382 - O383 -P384 - Q385 - R386 - S387 - T388 - U389 - V390 - W391 - X392 - Y393 - Z394
Befehl Kurzbeschreibunglapply(xfunc)395 lapply ermoumlglicht es die selbe Funktion func auf
eine Liste x von Objekten anzuwenden lapply ist da-mit eine (idR bessere) Alternative zur Benutzung vonSchleifenLoop-Konstruktionen
length(x)396 Mit length(x) wird die Anzahl der Elemente von x ermit-telt
level(x)397 Mit level(x) werden die Level x zuruumlckgegeben Da-bei kann x ein Vector oder eine zB eine Spalte einesdataframe sein
library()398 library() gibt eine Liste aller installierten Pakete (pa-ckages) ausMit library(package) wird ein Bibliothekeingebunden
lines(xy)399 lines(xy) verbindet mit den Vektoren x und y uumlbergebe-ne Punktkoordinaten mit Linien
369 Kapitel 511 auf Seite 197370 Kapitel 512 auf Seite 198371 Kapitel 513 auf Seite 199372 Kapitel 514 auf Seite 201373 Kapitel 515 auf Seite 202374 Kapitel 516 auf Seite 203375 Kapitel 517 auf Seite 204376 Kapitel 518 auf Seite 205377 Kapitel 519 auf Seite 206378 Kapitel 5110 auf Seite 208379 Kapitel 5111 auf Seite 209380 Kapitel 5112 auf Seite 210381 Kapitel 5113 auf Seite 211382 Kapitel 5114 auf Seite 213383 Kapitel 5115 auf Seite 214384 Kapitel 5116 auf Seite 215385 Kapitel 5117 auf Seite 217386 Kapitel 5118 auf Seite 218387 Kapitel 5119 auf Seite 219388 Kapitel 5120 auf Seite 222389 Kapitel 5121 auf Seite 223390 Kapitel 5122 auf Seite 224391 Kapitel 5123 auf Seite 225392 Kapitel 5124 auf Seite 226393 Kapitel 5125 auf Seite 227394 Kapitel 5126 auf Seite 228395 httpdewikibooksorgwikiGNU20R3A20lapply396 httpdewikibooksorgwikiGNU20R3A20length397 httpdewikibooksorgwikiGNU20R3A20level398 httpdewikibooksorgwikiGNU20R3A20library399 httpdewikibooksorgwikiGNU20R3A20lines
210
M
listfiles()400 listfiles() zeigt die Dateien des aktuellen Arbeits-verzeichnises an Alternativ kann auch dir() verwendetwerden
load(file)401 load(file) laumld eine gespeicherte R-Sitzung in den Ar-beitsspeicher
loadedNamespaces()402 loadedNamespaces() liefert eine Liste der aktuellenNamensraumlume
ls()403 ls() nennt alle Variablen in der aktuellen R-Sitzung (genauso wie objects()404)
lsstr()405 lsstr() listet alle Objekte der aktuellen R-Sitzung mitihrer Struktur Es handelt sich also um eine Kombination vonls()406 und str()407
5113 M
A408 - B409 - C410 - D411 - E412 - F413 - G414 - H415 - I416 - J417 - K418 - L419 - M420 - N421 - O422 -P423 - Q424 - R425 - S426 - T427 - U428 - V429 - W430 - X431 - Y432 - Z433
400 httpdewikibooksorgwikiGNU20R3A20listfiles401 httpdewikibooksorgwikiGNU20R3A20load402 httpdewikibooksorgwikiGNU20R3A20loadedNamespaces403 httpdewikibooksorgwikiGNU20R3A20ls404 httpdewikibooksorgwikiGNU20R3A20objects405 httpdewikibooksorgwikiGNU20R3A20lsstr406 httpdewikibooksorgwikiGNU20R3A20ls407 httpdewikibooksorgwikiGNU20R3A20str408 Kapitel 511 auf Seite 197409 Kapitel 512 auf Seite 198410 Kapitel 513 auf Seite 199411 Kapitel 514 auf Seite 201412 Kapitel 515 auf Seite 202413 Kapitel 516 auf Seite 203414 Kapitel 517 auf Seite 204415 Kapitel 518 auf Seite 205416 Kapitel 519 auf Seite 206417 Kapitel 5110 auf Seite 208418 Kapitel 5111 auf Seite 209419 Kapitel 5112 auf Seite 210420 Kapitel 5113 auf Seite 211421 Kapitel 5114 auf Seite 213422 Kapitel 5115 auf Seite 214423 Kapitel 5116 auf Seite 215424 Kapitel 5117 auf Seite 217425 Kapitel 5118 auf Seite 218426 Kapitel 5119 auf Seite 219427 Kapitel 5120 auf Seite 222428 Kapitel 5121 auf Seite 223429 Kapitel 5122 auf Seite 224430 Kapitel 5123 auf Seite 225431 Kapitel 5124 auf Seite 226432 Kapitel 5125 auf Seite 227433 Kapitel 5126 auf Seite 228
211
Befehle-Index
Befehl Kurzbeschreibungmap()434 map() (aus den Paketen maps und mapdata) erstellt Karten von
Laumlndern Kontinenten und der Weltmatch()435 match(vs)durchsucht einen Vektor B nach Uumlbereinstimmungen
in einem Suchvektor smatrix(abc)436 matrix(abc) fuumlhrt die Objekte a b c zu einer Matrix
zusammenmean(x)437 mean(x)bestimmt das arithmetische Mittel eines Zahlenvektors xmedian(x)438 median(x)bestimmt den Median eines Zahlenvektors xmetaplot439 metaplot erzeugt ein so genanntes Forest Plot (Meta-Analyse-
Plot) welches im Rahmen von Metaanalysen gaumlngig ist (siehe auchforestplot440)
mode(x)441 mode(x) uumlberpruumlft von welchem Typ das Objekt x ist Als Ant-wort wird entsprechend character numeric ausgegeben
434 httpdewikibooksorgwikiGNU20R3A20map435 httpdewikibooksorgwikiGNU20R3A20match436 httpdewikibooksorgwikiGNU20R3A20matrix437 httpdewikibooksorgwikiGNU20R3A20mean438 httpdewikibooksorgwikiGNU20R3A20median439 httpdewikibooksorgwikiGNU20R3A20metaplot440 httpdewikibooksorgwikiGNU_R3A20forestplot441 httpdewikibooksorgwikiGNU20R3A20mode
212
N
5114 N
A442 - B443 - C444 - D445 - E446 - F447 - G448 - H449 - I450 - J451 - K452 - L453 - M454 - N455 - O456 -P457 - Q458 - R459 - S460 - T461 - U462 - V463 - W464 - X465 - Y466 - Z467
Befehl Kurzbeschreibungnaomit(x)468 naomit(x) filtert (fuumlr Berechungen) die fehlenden Werte (missing
data NA) aus dem Objekt x herausnames(x)469 names(x) gibt die Variablennamen des Data-Frames x annchar(x)470 nchar(x) gibt Anzahl der Buchstaben in x anncol(x)471 ncol(x) gibt Anzahl der Spalten in x annrow(x)472 nrow(x) gibt Anzahl der Zeilen in x an
442 Kapitel 511 auf Seite 197443 Kapitel 512 auf Seite 198444 Kapitel 513 auf Seite 199445 Kapitel 514 auf Seite 201446 Kapitel 515 auf Seite 202447 Kapitel 516 auf Seite 203448 Kapitel 517 auf Seite 204449 Kapitel 518 auf Seite 205450 Kapitel 519 auf Seite 206451 Kapitel 5110 auf Seite 208452 Kapitel 5111 auf Seite 209453 Kapitel 5112 auf Seite 210454 Kapitel 5113 auf Seite 211455 Kapitel 5114 auf Seite 213456 Kapitel 5115 auf Seite 214457 Kapitel 5116 auf Seite 215458 Kapitel 5117 auf Seite 217459 Kapitel 5118 auf Seite 218460 Kapitel 5119 auf Seite 219461 Kapitel 5120 auf Seite 222462 Kapitel 5121 auf Seite 223463 Kapitel 5122 auf Seite 224464 Kapitel 5123 auf Seite 225465 Kapitel 5124 auf Seite 226466 Kapitel 5125 auf Seite 227467 Kapitel 5126 auf Seite 228468 httpdewikibooksorgwikiGNU20R3A20naomit469 httpdewikibooksorgwikiGNU20R3A20names470 httpdewikibooksorgwikiGNU20R3A20nchar471 httpdewikibooksorgwikiGNU20R3A20nccol472 httpdewikibooksorgwikiGNU20R3A20nrow
213
Befehle-Index
5115 O
A473 - B474 - C475 - D476 - E477 - F478 - G479 - H480 - I481 - J482 - K483 - L484 - M485 - N486 - O487 -P488 - Q489 - R490 - S491 - T492 - U493 - V494 - W495 - X496 - Y497 - Z498
Befehl Kurzbeschreibungobjects()499 objects() nennt alle Variablen in der aktuellen R-Sitzung (genau so
wie ls()500)odfWeave()501 odfWeave() ersetzt die in Open Office Dokumenten integrierten R-
Anweisungen durch die resultierenden Textausgaben Tabellen undGraphiken
options()502 options() ermoumlglicht Abfrage und Setzen globaler Voreinstellungenwie Textausgabeeigenschaften GraphicDevice etc
order()503 Der Befehl order(OBJEKT$x) ordnet den Datensatz OBJEKT an-hand des dort enthaltenen metrischen Vektor x in aufsteigender Reihen-folge
473 Kapitel 511 auf Seite 197474 Kapitel 512 auf Seite 198475 Kapitel 513 auf Seite 199476 Kapitel 514 auf Seite 201477 Kapitel 515 auf Seite 202478 Kapitel 516 auf Seite 203479 Kapitel 517 auf Seite 204480 Kapitel 518 auf Seite 205481 Kapitel 519 auf Seite 206482 Kapitel 5110 auf Seite 208483 Kapitel 5111 auf Seite 209484 Kapitel 5112 auf Seite 210485 Kapitel 5113 auf Seite 211486 Kapitel 5114 auf Seite 213487 Kapitel 5115 auf Seite 214488 Kapitel 5116 auf Seite 215489 Kapitel 5117 auf Seite 217490 Kapitel 5118 auf Seite 218491 Kapitel 5119 auf Seite 219492 Kapitel 5120 auf Seite 222493 Kapitel 5121 auf Seite 223494 Kapitel 5122 auf Seite 224495 Kapitel 5123 auf Seite 225496 Kapitel 5124 auf Seite 226497 Kapitel 5125 auf Seite 227498 Kapitel 5126 auf Seite 228499 httpdewikibooksorgwikiGNU20R3A20objects500 httpdewikibooksorgwikiGNU20R3A20ls501 httpdewikibooksorgwikiGNU20R3A20odfWeave502 Kapitel 56 auf Seite 239503 httpdewikibooksorgwikiGNU20R3A20order
214
P
5116 P
A504 - B505 - C506 - D507 - E508 - F509 - G510 - H511 - I512 - J513 - K514 - L515 - M516 - N517 - O518 -P519 - Q520 - R521 - S522 - T523 - U524 - V525 - W526 - X527 - Y528 - Z529
Befehl Kurzbeschreibungpairs()530 pair() ist eine Funktion zum Zeichnen einer Scatterplot-
Matrixpar()531 par() ist eine Funktion zum Setzen grafischer Parameterpackageskeleton()532 packageskeleton() erstellt automatisch die Grund-
struktur fuumlr neue (selbstprogrammierte) Zusatzpaketepaste(abc)533 Mit paste(abc) koumlnnen beliebig viele Argumente (a b
c beliebig) ausgeprintet werdenpdf()534 Mit Hilfe von pdf() koumlnnen Graphiken im weit verbreite-
ten pdf-Format gespeichert werdenpersp()535 Mit persp() koumlnnen dreidimensionalen Abbildungen er-
stellt werdenpie()536 Mit pie() koumlnnen Kreisdiagramme erstellt werden
504 Kapitel 511 auf Seite 197505 Kapitel 512 auf Seite 198506 Kapitel 513 auf Seite 199507 Kapitel 514 auf Seite 201508 Kapitel 515 auf Seite 202509 Kapitel 516 auf Seite 203510 Kapitel 517 auf Seite 204511 Kapitel 518 auf Seite 205512 Kapitel 519 auf Seite 206513 Kapitel 5110 auf Seite 208514 Kapitel 5111 auf Seite 209515 Kapitel 5112 auf Seite 210516 Kapitel 5113 auf Seite 211517 Kapitel 5114 auf Seite 213518 Kapitel 5115 auf Seite 214519 Kapitel 5116 auf Seite 215520 Kapitel 5117 auf Seite 217521 Kapitel 5118 auf Seite 218522 Kapitel 5119 auf Seite 219523 Kapitel 5120 auf Seite 222524 Kapitel 5121 auf Seite 223525 Kapitel 5122 auf Seite 224526 Kapitel 5123 auf Seite 225527 Kapitel 5124 auf Seite 226528 Kapitel 5125 auf Seite 227529 Kapitel 5126 auf Seite 228530 httpdewikibooksorgwikiGNU20R3A20pairs531 httpdewikibooksorgwikiGNU20R3A20par532 httpdewikibooksorgwikiGNU20R3A20packageskeleton533 httpdewikibooksorgwikiGNU20R3A20paste534 httpdewikibooksorgwikiGNU20R3A20pdf535 httpdewikibooksorgwikiGNU20R3A20persp536 httpdewikibooksorgwikiGNU20R3A20pie
215
Befehle-Index
plot(xy)537 plot(xy) ist die universelle Funktion zur Erzeugung vonStreudiagrammen und Linienzuumlgen aus den Vektoren x undy
png()538 Mit Hilfe von png() koumlnnen Graphiken in eine png-Dateigespeichert werden Fuumlr das jpeg-Format steht der Befehljpeg()539 zur Verfuumlgung
polygon(xy)540 Mit der Grafikfunktion polygon(xy) koumlnnen Grafikenmit beliebigen geschlossenen Linienzuumlgen erweitert werden
postscript()541 postscript() speichert die Grafikausgabe in einePostscript-Datei
primefactor(x)542 primefactor(x) (aus dem schoolmath-Paket) zer-legt die Zahl x in ihre Primfaktoren
primes(xy)543 primes(xy) (aus dem schoolmath-Paket) zeigt diePrimzahlen an welche sich zwischen x und y befinden
print544 print(x) gibt das Objekt x entsprechend seiner definier-ten Methode auf dem Bildschirmdas Standardgeraumlt aus
princomp(x)545 princomp(x) fuumlhrt eine Hauptkomponentenanalyse aufdas Objekt x durch (siehe auch factanal(x)546)
537 httpdewikibooksorgwikiGNU20R3A20plot538 httpdewikibooksorgwikiGNU20R3A20png539 httpdewikibooksorgwikiGNU20R3A20jpeg540 httpdewikibooksorgwikiGNU20R3A20polygon541 httpdewikibooksorgwikiGNU20R3A20postscript542 httpdewikibooksorgwikiGNU20R3A20primefactor543 httpdewikibooksorgwikiGNU20R3A20primes544 httpdewikibooksorgwikiGNU20R3A20print545 httpdewikibooksorgwikiGNU20R3A20princomp546 httpdewikibooksorgwikiGNU20R3A20factanal
216
Q
5117 Q
A547 - B548 - C549 - D550 - E551 - F552 - G553 - H554 - I555 - J556 - K557 - L558 - M559 - N560 - O561 -P562 - Q563 - R564 - S565 - T566 - U567 - V568 - W569 - X570 - Y571 - Z572
Befehl Kurzbeschreibungquit()573 q()574 quit() bzw q() beendet R
547 Kapitel 511 auf Seite 197548 Kapitel 512 auf Seite 198549 Kapitel 513 auf Seite 199550 Kapitel 514 auf Seite 201551 Kapitel 515 auf Seite 202552 Kapitel 516 auf Seite 203553 Kapitel 517 auf Seite 204554 Kapitel 518 auf Seite 205555 Kapitel 519 auf Seite 206556 Kapitel 5110 auf Seite 208557 Kapitel 5111 auf Seite 209558 Kapitel 5112 auf Seite 210559 Kapitel 5113 auf Seite 211560 Kapitel 5114 auf Seite 213561 Kapitel 5115 auf Seite 214562 Kapitel 5116 auf Seite 215563 Kapitel 5117 auf Seite 217564 Kapitel 5118 auf Seite 218565 Kapitel 5119 auf Seite 219566 Kapitel 5120 auf Seite 222567 Kapitel 5121 auf Seite 223568 Kapitel 5122 auf Seite 224569 Kapitel 5123 auf Seite 225570 Kapitel 5124 auf Seite 226571 Kapitel 5125 auf Seite 227572 Kapitel 5126 auf Seite 228573 httpdewikibooksorgwikiGNU20R3A20quit574 httpdewikibooksorgwikiGNU20R3A20quit
217
Befehle-Index
5118 R
A575 - B576 - C577 - D578 - E579 - F580 - G581 - H582 - I583 - J584 - K585 - L586 - M587 - N588 - O589 -P590 - Q591 - R592 - S593 - T594 - U595 - V596 - W597 - X598 - Y599 - Z600
Befehl Kurzbeschreibungrbind()601 mit rbind(abc) lassen sich die Vektoren a b und c
reihenweise zu einer Matrix zusammenfuumlhren (siehe auchcbind()602)
readcsv(file)603 readcsv(file) liest eine ASCII-Datei file welche imamerikanischen CSV-Format vorliegt ein
readcsv2(file)604 readcsv2(file) liest eine ASCII-Datei file welche imdeutschen CSV-Format vorliegt ein
readtable(file)605 readtable(file) liest eine Tabelle welche in der ASCII-Datei file vorliegt ein
rep(x n)606 rep(x n) gibt n Wiederholungen des Elements x zuruumlckrev(x)607 rev(x) dreht die Reihenfolge der Zahlenreihe x umrm(x)608 rm(x) loumlscht das Objekt x aus dem Arbeitsspeicher
575 Kapitel 511 auf Seite 197576 Kapitel 512 auf Seite 198577 Kapitel 513 auf Seite 199578 Kapitel 514 auf Seite 201579 Kapitel 515 auf Seite 202580 Kapitel 516 auf Seite 203581 Kapitel 517 auf Seite 204582 Kapitel 518 auf Seite 205583 Kapitel 519 auf Seite 206584 Kapitel 5110 auf Seite 208585 Kapitel 5111 auf Seite 209586 Kapitel 5112 auf Seite 210587 Kapitel 5113 auf Seite 211588 Kapitel 5114 auf Seite 213589 Kapitel 5115 auf Seite 214590 Kapitel 5116 auf Seite 215591 Kapitel 5117 auf Seite 217592 Kapitel 5118 auf Seite 218593 Kapitel 5119 auf Seite 219594 Kapitel 5120 auf Seite 222595 Kapitel 5121 auf Seite 223596 Kapitel 5122 auf Seite 224597 Kapitel 5123 auf Seite 225598 Kapitel 5124 auf Seite 226599 Kapitel 5125 auf Seite 227600 Kapitel 5126 auf Seite 228601 httpdewikibooksorgwikiGNU20R3A20rbind602 Kapitel 513 auf Seite 199603 httpdewikibooksorgwikiGNU20R3A20readcsv604 httpdewikibooksorgwikiGNU20R3A20readcsv2605 httpdewikibooksorgwikiGNU20R3A20readtable606 httpdewikibooksorgwikiGNU20R3A20rep607 httpdewikibooksorgwikiGNU20R3A20rev608 httpdewikibooksorgwikiGNU20R3A20rm
218
S
rnorm(n)609 rnorm(n) erzeugt n normalverteilte Zufallszahlenround(x)610 round(x) rundet die Zahl x auf oder abrownames()611 rownames() weist den Reihen einer Matrix einen Namen
(Label) zu Siehe colnames()612 fuumlr Spalten)
5119 S
A613 - B614 - C615 - D616 - E617 - F618 - G619 - H620 - I621 - J622 - K623 - L624 - M625 - N626 - O627 -P628 - Q629 - R630 - S631 - T632 - U633 - V634 - W635 - X636 - Y637 - Z638
Befehl Kurzbeschreibungsample(x)639 Mit sample(x) kann ein Vektor umgruppiert oder
Teilstichproben daraus gezogen werdensapply(xfunc)640 sapply ermoumlglicht es die selbe Funktion func
auf eine Liste x von Objekten anzuwenden und gibtdas Ergebnis als Vektor aus
save()641 save() speichert ausgewaumlhlte Objekte in eineDatei
609 httpdewikibooksorgwikiGNU20R3A20rnorm610 httpdewikibooksorgwikiGNU20R3A20round611 httpdewikibooksorgwikiGNU20R3A20rownames612 httpdewikibooksorgwikiGNU20R3A20colnames613 Kapitel 511 auf Seite 197614 Kapitel 512 auf Seite 198615 Kapitel 513 auf Seite 199616 Kapitel 514 auf Seite 201617 Kapitel 515 auf Seite 202618 Kapitel 516 auf Seite 203619 Kapitel 517 auf Seite 204620 Kapitel 518 auf Seite 205621 Kapitel 519 auf Seite 206622 Kapitel 5110 auf Seite 208623 Kapitel 5111 auf Seite 209624 Kapitel 5112 auf Seite 210625 Kapitel 5113 auf Seite 211626 Kapitel 5114 auf Seite 213627 Kapitel 5115 auf Seite 214628 Kapitel 5116 auf Seite 215629 Kapitel 5117 auf Seite 217630 Kapitel 5118 auf Seite 218631 Kapitel 5119 auf Seite 219632 Kapitel 5120 auf Seite 222633 Kapitel 5121 auf Seite 223634 Kapitel 5122 auf Seite 224635 Kapitel 5123 auf Seite 225636 Kapitel 5124 auf Seite 226637 Kapitel 5125 auf Seite 227638 Kapitel 5126 auf Seite 228639 httpdewikibooksorgwikiGNU20R3A20sample640 httpdewikibooksorgwikiGNU20R3A20sapply641 httpdewikibooksorgwikiGNU20R3A20save
219
Befehle-Index
saveimage(fileRData)642 saveimage(fileRData) speichert denaktuellen Arbeitsspeicher
savePlot()643 savePlot() speichert die aktuelle Grafik in eineDatei
scan()644 scan() ermoumlglicht eine manuelle Dateneingabe fuumlreinen Vektor
scm(xy)645 scm(xy) (aus dem schoolmath-Paket) berech-net das kleinste gemeinsame Vielfache der Zahlen xund y
search()646 search() zeigt die Suchliste an unter anderemauch geladene Bibliotheken
searchpaths()647 searchpaths() zeigt die Suchliste mit Pfadanga-ben der geladenen Bibliotheken an
seq()648 Mit Hilfe von seq() kann eine Datensequenz er-stellt werden
setdiff(x y)649 setdiff(x y) gibt die Elemente von x dienicht in y enthalten sind als neuen Vektor aus Funk-tioniert auch umgekehrt mit setdiff(y x)
setequal(x y)650 setequal(x y) untersucht beide Vektoren aufGleichheit und gibt TRUEFALSE aus
setwd(dir)651 Mit setwd(dir) kann das Arbeitsverzeichnisgeaumlndert werden
shapirotest(x)652 shapirotest(x) fuumlhrt einen Shapiro-Wilk-Test auf die Zahlenreihe x durch Hierdurch wirdbestimmt ob die Zahlenreihe x normalverteilt ist
sink()653 sink() leitet den Konsolen-Output in eine Dateium
sort()654 Der Befehl sort(x) ordnet den metrischen Vektorx in aufsteigender Reihenfolge (siehe order()655
zum sortieren eines Datensatzes)source()656 Mit dem Befehl source() werden R-Skripte gela-
den und sofort ausgefuumlhrtsqrt(x)657 sqrt(x) zieht die Quadratwurzel aus der Zahl x
642 httpdewikibooksorgwikiGNU20R3A20saveimage643 httpdewikibooksorgwikiGNU20R3A20savePlot644 httpdewikibooksorgwikiGNU20R3A20scan645 httpdewikibooksorgwikiGNU20R3A20scm646 httpdewikibooksorgwikiGNU20R3A20search647 httpdewikibooksorgwikiGNU20R3A20searchpaths648 httpdewikibooksorgwikiGNU20R3A20seq649 httpdewikibooksorgwikiGNU20R3A20setdiff650 httpdewikibooksorgwikiGNU20R3A20setequal651 httpdewikibooksorgwikiGNU20R3A20setwd652 httpdewikibooksorgwikiGNU20R3A20shapirotest653 httpdewikibooksorgwikiGNU20R3A20sink654 httpdewikibooksorgwikiGNU20R3A20sort655 httpdewikibooksorgwikiGNU20R3A20order656 httpdewikibooksorgwikiGNU20R3A20source657 httpdewikibooksorgwikiGNU20R3A20sqrt
220
S
str()658 str() gibt Auskunft uumlber die Struktur von R-Objekten
strptime()659 strptime() wandelt Datum- und Zeitangaben indas Format POSIXlt bzw POSIXct um
strsplit()660 strsplit() spaltet eine Zeichenkette abhaumlngigvom angegebenen Muster
sub()661 Mit sub(MusterErsetzungObjekt)lassen sich Zeichenketten in einem Objekt ersetzen
subset()662 Mit subset() laumlsst sich eine Teilgruppe von Da-ten aus einem dataframe663 bilden
sum()664 Mit sum() wird die Summe der uumlbergebenen Wertebestimmt
summary()665 Mit summary() lassen sich das Minimum dasMaximum das 1 und 3 Quantil sowie Mittelwertund der Median von Verteilungen ausgeben
Sweave()666 Sweave() ersetzt die in (La)Tex-Dokumenten in-tegrierten R-Anweisungen durch die resultierendenTextausgaben Tabellen oder generiert Graphikenund bindet diese automatisch in die Tex-Datei ein
Systime()667 Systime() liefert das aktuelle Datum und die ak-tuelle Uhrzeit im Format POSIXlt bzw POSIXct
658 httpdewikibooksorgwikiGNU20R3A20str659 httpdewikibooksorgwikiGNU20R3A20strptime660 httpdewikibooksorgwikiGNU20R3A20strsplit661 httpdewikibooksorgwikiGNU20R3A20sub662 httpdewikibooksorgwikiGNU20R3A20subset663 httpdewikibooksorgwikiGNU20R3A20dataframe664 httpdewikibooksorgwikiGNU20R3A20sum665 httpdewikibooksorgwikiGNU20R3A20summary666 httpdewikibooksorgwikiGNU20R3A20Sweave667 httpdewikibooksorgwikiGNU20R3A20Systime
221
Befehle-Index
5120 T
A668 - B669 - C670 - D671 - E672 - F673 - G674 - H675 - I676 - J677 - K678 - L679 - M680 - N681 - O682 -P683 - Q684 - R685 - S686 - T687 - U688 - V689 - W690 - X691 - Y692 - Z693
Befehl Kurzbeschreibungttest()694 ttest() fuumlhrt einen t-Test (und bei Bedarf einen Welch-Test) durchtable()695 Mit table() werden Haumlufigkeitstabellen erstellttail()696 Mit dem Befehl tail(DATA n) lassen sich die letzten n Datenrei-
hen des Datensatzes DATA anzeigen Der Befehl head()697 lieferthingegen die ersten n Datenreihen
tan(x)698 tan(x) berechnet den Tangens von xtitle()699 title() ermoumlglicht das (nachtraumlgliche) Beschriften von Grafikentolower(x)700 tolower(x) wandelt den String x in Kleinbuchstaben umtoupper(x)701 toupper(x) wandelt den String x in Groszligbuchstaben um
668 Kapitel 511 auf Seite 197669 Kapitel 512 auf Seite 198670 Kapitel 513 auf Seite 199671 Kapitel 514 auf Seite 201672 Kapitel 515 auf Seite 202673 Kapitel 516 auf Seite 203674 Kapitel 517 auf Seite 204675 Kapitel 518 auf Seite 205676 Kapitel 519 auf Seite 206677 Kapitel 5110 auf Seite 208678 Kapitel 5111 auf Seite 209679 Kapitel 5112 auf Seite 210680 Kapitel 5113 auf Seite 211681 Kapitel 5114 auf Seite 213682 Kapitel 5115 auf Seite 214683 Kapitel 5116 auf Seite 215684 Kapitel 5117 auf Seite 217685 Kapitel 5118 auf Seite 218686 Kapitel 5119 auf Seite 219687 Kapitel 5120 auf Seite 222688 Kapitel 5121 auf Seite 223689 Kapitel 5122 auf Seite 224690 Kapitel 5123 auf Seite 225691 Kapitel 5124 auf Seite 226692 Kapitel 5125 auf Seite 227693 Kapitel 5126 auf Seite 228694 httpdewikibooksorgwikiGNU20R3A20ttest695 httpdewikibooksorgwikiGNU20R3A20table696 httpdewikibooksorgwikiGNU20R3A20tail697 httpdewikibooksorgwikiGNU20R3A20head698 httpdewikibooksorgwikiGNU20R3A20tan699 httpdewikibooksorgwikiGNU20R3A20title700 httpdewikibooksorgwikiGNU20R3A20tolower701 httpdewikibooksorgwikiGNU20R3A20toupper
222
U
5121 U
A702 - B703 - C704 - D705 - E706 - F707 - G708 - H709 - I710 - J711 - K712 - L713 - M714 - N715 - O716 -P717 - Q718 - R719 - S720 - T721 - U722 - V723 - W724 - X725 - Y726 - Z727
Befehl Kurzbeschreibungunion(x y)728 union(x y) vereiningt die Werte des Vektors x mit den
Werten des Vektors y die nicht bereits in x enthalten sindUmgekehrt funktioniert auch union(y x)
unique()729 unique(data) uumlberpruumlft den Datensatz data auf doppel-te bzw mehrfache Eintraumlge und liefert den Datensatz ohneDuplikate zuruumlck (siehe auch duplicated()730)
unlink()731 unlink() loumlscht eine Datei oder ein Verzeichnisupdate(x)732 update(x) erweitert das bestehende Modell xupdatepackages()733 updatepackages() aktualisiert die geladenen R-Basis-
und Zusatzpakete
702 Kapitel 511 auf Seite 197703 Kapitel 512 auf Seite 198704 Kapitel 513 auf Seite 199705 Kapitel 514 auf Seite 201706 Kapitel 515 auf Seite 202707 Kapitel 516 auf Seite 203708 Kapitel 517 auf Seite 204709 Kapitel 518 auf Seite 205710 Kapitel 519 auf Seite 206711 Kapitel 5110 auf Seite 208712 Kapitel 5111 auf Seite 209713 Kapitel 5112 auf Seite 210714 Kapitel 5113 auf Seite 211715 Kapitel 5114 auf Seite 213716 Kapitel 5115 auf Seite 214717 Kapitel 5116 auf Seite 215718 Kapitel 5117 auf Seite 217719 Kapitel 5118 auf Seite 218720 Kapitel 5119 auf Seite 219721 Kapitel 5120 auf Seite 222722 Kapitel 5121 auf Seite 223723 Kapitel 5122 auf Seite 224724 Kapitel 5123 auf Seite 225725 Kapitel 5124 auf Seite 226726 Kapitel 5125 auf Seite 227727 Kapitel 5126 auf Seite 228728 httpdewikibooksorgwikiGNU20R3A20union729 httpdewikibooksorgwikiGNU20R3A20unique730 httpdewikibooksorgwikiGNU20R3A20duplicated731 httpdewikibooksorgwikiGNU20R3A20unlink732 httpdewikibooksorgwikiGNU20R3A20update733 httpdewikibooksorgwikiGNU20R3A20updatepackages
223
Befehle-Index
5122 V
A734 - B735 - C736 - D737 - E738 - F739 - G740 - H741 - I742 - J743 - K744 - L745 - M746 - N747 - O748 -P749 - Q750 - R751 - S752 - T753 - U754 - V755 - W756 - X757 - Y758 - Z759
Befehl Kurzbeschreibungvar(xy)760 var(xy) berechnet die Varianz oder Kovarianz der Variable x
bzw der Variablen x und yvartest(xy)761 vartest(xy) fuumlhrt einen Varianzquotienten-Test (F-Test)
durch
734 Kapitel 511 auf Seite 197735 Kapitel 512 auf Seite 198736 Kapitel 513 auf Seite 199737 Kapitel 514 auf Seite 201738 Kapitel 515 auf Seite 202739 Kapitel 516 auf Seite 203740 Kapitel 517 auf Seite 204741 Kapitel 518 auf Seite 205742 Kapitel 519 auf Seite 206743 Kapitel 5110 auf Seite 208744 Kapitel 5111 auf Seite 209745 Kapitel 5112 auf Seite 210746 Kapitel 5113 auf Seite 211747 Kapitel 5114 auf Seite 213748 Kapitel 5115 auf Seite 214749 Kapitel 5116 auf Seite 215750 Kapitel 5117 auf Seite 217751 Kapitel 5118 auf Seite 218752 Kapitel 5119 auf Seite 219753 Kapitel 5120 auf Seite 222754 Kapitel 5121 auf Seite 223755 Kapitel 5122 auf Seite 224756 Kapitel 5123 auf Seite 225757 Kapitel 5124 auf Seite 226758 Kapitel 5125 auf Seite 227759 Kapitel 5126 auf Seite 228760 httpdewikibooksorgwikiGNU20R3A20var761 httpdewikibooksorgwikiGNU20R3A20vartest
224
W
5123 W
A762 - B763 - C764 - D765 - E766 - F767 - G768 - H769 - I770 - J771 - K772 - L773 - M774 - N775 - O776 -P777 - Q778 - R779 - S780 - T781 - U782 - V783 - W784 - X785 - Y786 - Z787
Befehl Kurzbeschreibungwhich()788 Die Funktion which() gibt an welche Indizes eines Objektes
den Wert TRUE besitzenwilcoxtest(xy)789 wilcoxtest(xy) fuumlhrt je nach Optionsgabe den
Wilcoxon-Test oder den Mann-Whitney-Test fuumlr x und y durchwilcox_-test(xy)790
wilcox_test(xy) (aus dem coin-Package) fuumlhrt denMann-Whitney-Test durch
write()791 write() schreibt Daten in eine Dateiwritetable()792 write() schreibt einen Data Table in eine Datei
762 Kapitel 511 auf Seite 197763 Kapitel 512 auf Seite 198764 Kapitel 513 auf Seite 199765 Kapitel 514 auf Seite 201766 Kapitel 515 auf Seite 202767 Kapitel 516 auf Seite 203768 Kapitel 517 auf Seite 204769 Kapitel 518 auf Seite 205770 Kapitel 519 auf Seite 206771 Kapitel 5110 auf Seite 208772 Kapitel 5111 auf Seite 209773 Kapitel 5112 auf Seite 210774 Kapitel 5113 auf Seite 211775 Kapitel 5114 auf Seite 213776 Kapitel 5115 auf Seite 214777 Kapitel 5116 auf Seite 215778 Kapitel 5117 auf Seite 217779 Kapitel 5118 auf Seite 218780 Kapitel 5119 auf Seite 219781 Kapitel 5120 auf Seite 222782 Kapitel 5121 auf Seite 223783 Kapitel 5122 auf Seite 224784 Kapitel 5123 auf Seite 225785 Kapitel 5124 auf Seite 226786 Kapitel 5125 auf Seite 227787 Kapitel 5126 auf Seite 228788 httpdewikibooksorgwikiGNU20R3A20which789 httpdewikibooksorgwikiGNU20R3A20wilcoxtest790 httpdewikibooksorgwikiGNU20R3A20wilcox_test791 httpdewikibooksorgwikiGNU20R3A20write792 httpdewikibooksorgwikiGNU20R3A20writetable
225
Befehle-Index
5124 X
A793 - B794 - C795 - D796 - E797 - F798 - G799 - H800 - I801 - J802 - K803 - L804 - M805 - N806 - O807 -P808 - Q809 - R810 - S811 - T812 - U813 - V814 - W815 - X816 - Y817 - Z818
Befehl Kurzbeschreibungx11()819 x11() oumlffnet ein Grafikfenster per X11xtabs()820 xtabs() dient dazu Kreuztabellen zu erstellen
793 Kapitel 511 auf Seite 197794 Kapitel 512 auf Seite 198795 Kapitel 513 auf Seite 199796 Kapitel 514 auf Seite 201797 Kapitel 515 auf Seite 202798 Kapitel 516 auf Seite 203799 Kapitel 517 auf Seite 204800 Kapitel 518 auf Seite 205801 Kapitel 519 auf Seite 206802 Kapitel 5110 auf Seite 208803 Kapitel 5111 auf Seite 209804 Kapitel 5112 auf Seite 210805 Kapitel 5113 auf Seite 211806 Kapitel 5114 auf Seite 213807 Kapitel 5115 auf Seite 214808 Kapitel 5116 auf Seite 215809 Kapitel 5117 auf Seite 217810 Kapitel 5118 auf Seite 218811 Kapitel 5119 auf Seite 219812 Kapitel 5120 auf Seite 222813 Kapitel 5121 auf Seite 223814 Kapitel 5122 auf Seite 224815 Kapitel 5123 auf Seite 225816 Kapitel 5124 auf Seite 226817 Kapitel 5125 auf Seite 227818 Kapitel 5126 auf Seite 228819 httpdewikibooksorgwikiGNU20R3A20x11820 httpdewikibooksorgwikiGNU20R3A20xtabs
226
Y
5125 Y
A821 - B822 - C823 - D824 - E825 - F826 - G827 - H828 - I829 - J830 - K831 - L832 - M833 - N834 - O835 -P836 - Q837 - R838 - S839 - T840 - U841 - V842 - W843 - X844 - Y845 - Z846
Befehl Kurzbeschreibung
821 Kapitel 511 auf Seite 197822 Kapitel 512 auf Seite 198823 Kapitel 513 auf Seite 199824 Kapitel 514 auf Seite 201825 Kapitel 515 auf Seite 202826 Kapitel 516 auf Seite 203827 Kapitel 517 auf Seite 204828 Kapitel 518 auf Seite 205829 Kapitel 519 auf Seite 206830 Kapitel 5110 auf Seite 208831 Kapitel 5111 auf Seite 209832 Kapitel 5112 auf Seite 210833 Kapitel 5113 auf Seite 211834 Kapitel 5114 auf Seite 213835 Kapitel 5115 auf Seite 214836 Kapitel 5116 auf Seite 215837 Kapitel 5117 auf Seite 217838 Kapitel 5118 auf Seite 218839 Kapitel 5119 auf Seite 219840 Kapitel 5120 auf Seite 222841 Kapitel 5121 auf Seite 223842 Kapitel 5122 auf Seite 224843 Kapitel 5123 auf Seite 225844 Kapitel 5124 auf Seite 226845 Kapitel 5125 auf Seite 227846 Kapitel 5126 auf Seite 228
227
Befehle-Index
5126 Z
A847 - B848 - C849 - D850 - E851 - F852 - G853 - H854 - I855 - J856 - K857 - L858 - M859 - N860 - O861 -P862 - Q863 - R864 - S865 - T866 - U867 - V868 - W869 - X870 - Y871 - Z872
Befehl Kurzbeschreibung
847 Kapitel 511 auf Seite 197848 Kapitel 512 auf Seite 198849 Kapitel 513 auf Seite 199850 Kapitel 514 auf Seite 201851 Kapitel 515 auf Seite 202852 Kapitel 516 auf Seite 203853 Kapitel 517 auf Seite 204854 Kapitel 518 auf Seite 205855 Kapitel 519 auf Seite 206856 Kapitel 5110 auf Seite 208857 Kapitel 5111 auf Seite 209858 Kapitel 5112 auf Seite 210859 Kapitel 5113 auf Seite 211860 Kapitel 5114 auf Seite 213861 Kapitel 5115 auf Seite 214862 Kapitel 5116 auf Seite 215863 Kapitel 5117 auf Seite 217864 Kapitel 5118 auf Seite 218865 Kapitel 5119 auf Seite 219866 Kapitel 5120 auf Seite 222867 Kapitel 5121 auf Seite 223868 Kapitel 5122 auf Seite 224869 Kapitel 5123 auf Seite 225870 Kapitel 5124 auf Seite 226871 Kapitel 5125 auf Seite 227872 Kapitel 5126 auf Seite 228
228
52 Loumlsung der Uumlbungsaufgaben
229
53 Umgang mit Datensaumltzen (ErstellenAuswaumlhlen und Filtern)
1 Lassen Sie sich die zweite und fuumlnfte Zeile von meinedaten ausgeben
meinedaten[c(25)]Name Geschlecht Lieblingsfarbe Einkommen
2 Caro weiblich blau 800
5 Samira weiblich gelb 899
2Lassen Sie nur die Namen der Personen ausgeben deren Lieblingsfarbe gelb ist
Gesucht sind die Faumllle deren Lieblingsfarbe gelb ist Die Namen stehen in der 1 Spalte
gt meinedaten[meinedaten$Lieblingsfarbe==gelb1]
[1] Lars Samira
zum selben Ergebnis fuumlhrt
gt meinedaten[meinedaten$Lieblingsfarbe==gelbName]
[1] Lars Samira
3 Welchen Namen und welches Geschlecht hat die Person mit dem niedrigsten Einkommen(Benutzen sie hierzu die Funktion rank(variable) die fuumlr eine gegebene Variable den Rang ineiner aufsteigend geordneten Liste liefert)
Gesucht ist also der Fall dessen Einkommen in einer geordneten Liste den ersten Rang hat Hierinteressieren uns nur die SpaltenVariablen Name und Geschlecht
meinedaten[rank(meinedaten$Einkommen)==1c(NameGeschlecht)]Name Geschlecht
2 Caro weiblich
231
54 Programmierbeispiele
Diese Seite sammelt die Programmierbeispiele fuumlr das Kapitel Programmieren mit R1
541 Beispiel 1 Abschlussnote
Eine (gedachte) Abschlussnote ergibt sich aus 3 Teilnoten Hierbei fliessen die ersten 2 Noten zu30 - und die dritte Note zu 40 in die Abschlussnote ein Wir programmieren uns also eine nettekleine Funktion die uns die Abschlussnote aus den Teilnoten errechnet
Abschlussnote lt- function2(xyz)xnote lt- (x100)30ynote lt- (y100)30znote lt- (z100)40abschluss lt- xnote + ynote + znotecat3 (Abschlussnote abschluss n)
Wir koumlnnen die Funktion nun aufrufen per Abschlussnote(x y z) wobei x y z durchdie jeweiligen Teilnoten ersetzt werden zB so
Abschlussnote(11 17 15)
Wir erhalten
Abschlussnote 144
542 Beispiel 2 Cut-Off-Points
Bestimmung des Cut-Off-Points eines Assessmentinstruments anhand von Sensitivitaumlt und Spezifitaumlt
Uumlbergeben werden muss der Funktion
bull ein Vektor x welcher die einzelnen Summenwerte (des Assessmentinstruments) enthaumlltbull ein Vektor y welcher fuumlr den entsprechenden Summenwert angibt ob ein Risiko vorliegt (bzw
Ereignis eintraf) oder nicht (zB 0 und 1 oder j und n)
1 Kapitel 41 auf Seite 145
233
Programmierbeispiele
bull der Parameter risk welcher angibt wodurch die positive Gruppe im Vektor y repraumlsentiert wird(so zB 0 oder 1 bzw j oder n)
bull der Paramter dir welcher anzeigtbull ob ein houmlherer Summenwert (x) die Chance zur positiven Gruppenzugehoumlrigkeit erhoumlht (dir=GREATER )
bull ob ein niedrigerer Summenwert (x) die Chance zur positiven Gruppenzugehoumlrigkeit erhoumlht (dir=LESS )
bull der Parameter plot welcher per TRUE FALSE angibt ob eine Graphik ausgegeben werdensoll oder nicht
sensspec lt- function4(xy risk=1 dir=LESS plot=F)
frame lt- dataframe5(xy)varmin lt- min6(naomit7(x))
welches ist der niedrigste Wertvarmax lt- max8(naomit9(x))
welches ist der houmlchste Wertdummy lt- varmin
cat10(r)cat(Minimum of value varmin r)cat(Maximum of value varmax r r)cat(Risk is coded with risk r)
if11 (tolower12(dir) in c(greater g)) cat13(greater value means higher risk r r)
if14 (tolower15(dir) in c(lessl)) cat16(lesser value means higher risk r r)
sesptable lt- cbind17(999 999 999 999 999 999 999) dient der Indizierung wird spaumlter geloumlscht (su)
while18(dummy lt= varmax) truefalse positivenegativeif19 (tolower20(dir) in c(lessl))
tp lt- length21(frame$x[frame$xlt=dummy ampframe$y==risk]) true positive
fp lt- length(frame$x[frame$xlt=dummy ampframe$y=risk]) false positive
tn lt- length(frame$x[frame$xgtdummy ampframe$y=risk]) true negative
fn lt- length(frame$x[frame$xgtdummy ampframe$y==risk]) false negative
if22 (tolower23(dir) in c(greater g)) tp lt- length24(frame$x[frame$xgt=dummy amp
frame$y==risk]) true positivefp lt- length(frame$x[frame$xgt=dummy amp
frame$y=risk]) false positivetn lt- length(frame$x[frame$xltdummy amp
frame$y=risk]) true negativefn lt- length(frame$x[frame$xltdummy amp
frame$y==risk]) false negative
sensi lt- round25((tp (tp+fn))digits=3) Sensitivitaumlt
speci lt- round((tn (tn+fp))digits=3)
234
Beispiel 3 Entfernen von Umlauten
Spezifitaumltsesptable lt- rbind26(sesptable c27(dummy sensi speci
tpfptnfn))dummy lt- (dummy+1)
colnames28(sesptable) lt- c(Value Sensitivy Specificy tpfp tn fn)
sesptable lt- sesptable[-1] hier werden die 999geloumlscht
if (plot==T) plottable lt- cbind29(sesptable[2] sesptable[3])plot30(plottable)
if (plot==F) print31(sesptable)cat(r)cat(Cut-Off-Points include positive cases r)cat(r)
sensspec(x y) Aufruf der Funktion
543 Beispiel 3 Entfernen von Umlauten
Diese Funktion entfernt stoumlrende Umlaute
noumlaute lt- function32(variable)
----------------------------------------------------------------------
Funktion entfernt stoerende Umlaute unten stehende Liste ggferweitern
----------------------------------------------------------------------
variable lt- gsub33(aumlaevariable)variable lt- gsub(uumluevariable)variable lt- gsub(oumloevariable)variable lt- gsub(UumlUevariable)variable lt- gsub(AumlAevariable)variable lt- gsub(OumlOevariable)variable lt- gsub(szligssvariable)return(variable)
235
Programmierbeispiele
544 Beispiel 4 Zeit Sampler
Diese Funktion erzeugt eine randomisierte Liste von je einem aller Wochentagen im MonatSeptember
randaylt-function34(name1 name2)name1 und name2 sind nur labels fuer denOutputstartdate lt- strptime35(20080901Ymd) erzeugt dasStartdaum welches dem ersten Montag im Montag entspricht
enddate lt- strptime(20080930Ymd) erzeugt dasEnddatum welches hier immer gleich ist
MON lt- seq(startdate enddate by=7 days) erzeugt dieSequenz vom Startdatum bis zum Enddatum alle 7 Tagestartdate lt- strptime(20080902Ymd) und legt dasErgebnis in einem Object ab
enddate lt- strptime(20080930Ymd)TUE lt- seq(startdate enddate by=7 days)
startdate lt- strptime(20080903Ymd)enddate lt- strptime(20080930Ymd)
WED lt- seq(startdate enddate by=7 days)startdate lt- strptime(20080904Ymd)
enddate lt- strptime(20080930Ymd)THU lt- seq(startdate enddate by=7 days)
startdate lt- strptime(20080905Ymd)enddate lt- strptime(20080930Ymd)
FRI lt- seq(startdate enddate by=7 days)startdate lt- strptime(20080906Ymd)
enddate lt- strptime(20080930Ymd)SAT lt- seq(startdate enddate by=7 days)
startdate lt- strptime(20080907Ymd)enddate lt- strptime(20080930Ymd)
SUN lt- seq(startdate enddate by=7 days)a lt- c(sample(MON1)sample(TUE1)s
ample(WED1)sample(THU1)sample(FRI1)sample(SAT1)sample(SUN1)) Sampling
a lt- sort(a)cat(Name 1 name1 Name 2 name2 n format(a a
mdy) n)
545 siehe auch
bull Programmieren mit R36
bull Anwendungsbeispiele37
36 Kapitel 41 auf Seite 14537 Kapitel 47 auf Seite 169
236
55 Beispielskripte
551 Importieren von SPSS-Datensaumltzen
Das folgende Skript verdeutlicht den Import von Variable Labels in SPSS der sich mit readspssetwas umstaumlndlich gestaltet
Zweck Das Skript laumldt eine SPSS-Datei incl Kommentaren
----------------------------------------------------------------------
Verwendung Pfad der SPSS-Datei und auszugebenden R-Datei in
spssfile und rfile definieren und ausfuumlhren Die exportierteR-Datei
ist dann im angegebenen Verzeichnis verfuumlgbar und kann mit
load (PfadzurDateirdateir) in SPSS eingebunden werden
GGf kann der Datensatzname a angepasst werden
----------------------------------------------------------------------
Author euro Date 30 May 2007 2143
SPSS-Datei
spssfile lt- PfadzurDateispssdateisav R-datei
rfile lt- PfadzurDateirdateir
noumlaute lt- function(variable)
----------------------------------------------------------------------
237
Beispielskripte
Funktion entfernt stoerende Umlaute unten stehende Listeggf erweitern
----------------------------------------------------------------------
variable lt- gsub(aumlaevariable)variable lt- gsub(uumluevariable)variable lt- gsub(oumloevariable)variable lt- gsub(UumlUevariable)variable lt- gsub(AumlAevariable)variable lt- gsub(OumlOevariable)variable lt- gsub(szligssvariable)return(variable)
library(foreign)
Sprachoptionen
ggf durch andere zu ersetzen
Syssetlocale(locale=de_DEISO8859-15)
eigentlicher Import
aspss lt- (readspss(spssfile))a lt- asdataframe(aspss)
Uumlbernahme der Kommentare in jede Variable des Datensatz a
cat( importing names)for (i in 1length(attr(aspssvariablelabels)))
comment(a[i]) lt-
noumlaute(attr(aspssvariablelabels)[i])cat ()
cat ( readyn)
Speichern der Datei
save(afile=rfile)
238
56 Uumlbersicht programmspezifischerVoreinstellungen
Die Anweisung
unlist ( options () )
ermoumlglicht die uumlbersichtliche Darstellung der programmspezifischen Voreinstellungen zB so
HTTPUserAgentOutDec
R (250 powerpc-apple-darwin891 powerpc darwin891) STERM
X11colortypeiESS true
X11fonts1X11fonts2
-adobe-helvetica-s-s---d------- -adobe-symbol-medium-r---d-------addsmooth
browserTRUE usrbinopen
Mit der Anweisung
options ( VOREINSTELLUNGSPARAMETER = NEUER WERT )
koumlnnen Voreinstellungen neu gesetzt werden
Wenn zB das Zeichen statt dem standardmaumlssigen fuumlr die Trennung von Kommawertenverwendet werden soll kann dies mit folgender Anweisung veraumlndert werden
options ( OutDec = )
Folgende Optionen gibt es
Parameter Funktion VoreinstellungOutDec Ausgabezeichen fuumlr Trennung von
Kommazahlen
STERMX11colortypeX11fontsaddsmooth
239
Uumlbersicht programmspezifischer Voreinstellungen
browser Kommando mit dem Html-Seiten unddie Html-basierte Hilfe dargestelltwird
checkboundscontinuecontrastsdevice Standard -gt Graphik X11digitsdvipscmdechoeditorencoding Zeichenkodieerung der TexteingabeexampleaskexpressionshelptryallpackagesinternetinfokeepsourcekeepsourcepkgslatexcmdlocatorBellmailer Standardprogramm fuumlr den Mailver-
sandmaxprintmenugraphicsnaaction naomitpagerpapersize Format fuumlr die Erstellung von druckfauml-
higen Dokumenten (bspw A4)paraskdefaultpdfviewer Standardprogramm fuumlr die Darstellung
von PDF-DokumentenpkgTypeprintcmdprompt Zeichen zur Markierung der Eingabe-
bereitschaftgt
reposshowcoefPvaluesshowerrormessagesshowsignifstarsstrstringsAsFactorstimeouttsScompattsepsunzip Anweisung zum automatischen Entpa-
cken von ZIP-Dateienusrbinunzip (Linux)
verbosewarn
240
Importieren von SPSS-Datensaumltzen
warningslength 1000width Ausgabebreite in Zeichen Zeile
241
57 Das wikibooks-Zusatzpaket
Fuumlr dieses Wikibook wurde ein eigenes Zusatzpaket1 erstellt Es beinhaltet die in diesem Buchverwendeten Funktionen und Datensaumltze
Der Name des Pakets lautet wikibooks
571 Installation
Zur Installation wird folgender Befehl verwendet
installpackages2(wikibooks)
Derzeit ist das Paket nur fuumlr die R-Version 25 vorkompiliert Falls Sie eine aumlltere R-Versionverwenden muumlssen Sie das Paket manuell installieren
1 Laden Sie das Paket hier3 herunter2 Oumlffnen Sie eine Shell3 Gehen Sie in das Verzeichnis in welches Sie das Paket heruntergeladen haben und geben Sie
ein
R CMD INSTALL wikibooks
572 Paket aktivieren
Nachdem das Paket installiert ist muumlssen Sie es per library4(wikibooks) aktivieren Erstjetzt stehen die Funktionen und Datensaumltze zur Verfuumlgung
Um einen Datensatz aus dem Paket verwenden zu koumlnnen muumlssen Sie auch diesen erst aktivie-ren Um beispielsweise auf den Bundesliga-Datensatz zugreifen zu koumlnnen geben Sie in dieR-Kommandozeile ein
data5(Bundesliga)
1 Kapitel 7 auf Seite 173 httpwwwcranr-projectorgwebpackageswikibooksindexhtml4 httpdewikibooksorgwikiGNU20R3A20library
243
Das wikibooks-Zusatzpaket
573 Paketinhalt
5731 Funktionen
Abschlussnote
Die Funktion Abschlussnote errechnet eine gedachte Abschlussnote welche aus drei Pruumlfungs-ergebnissen zusammengesetzt wird (vgl Programmierbeispiel 16)
Abschlussnote(17 24 30)
BundesligaMannschaft
Diese Funktion benoumltigt den Bundesliga7-Datensatz und sucht alle Spielpaarungen undErgebnisse einer Mannschaft fuumlr eine spezifische bzw fuumlr alle verfuumlgbaren Saisons heraus DieStandardeinstellungen lauten
BundesligaMannschaft(Mannschaft Saison = all)
Um sich beispielsweise die Paarungen des FC Schalke 04 fuumlr alle Saisons anzeigen zu lassen wirddie Funktion aufgerufen per
BundesligaMannschaft(FC Schalke 04)
Interessiert man sich nur fuumlr die Paarungen der Saison 19992000 lautet der Aufruf
BundesligaMannschaft(FC Schalke 04 19992000)
BundesligaTabelle
Diese Funktion benoumltigt den Bundesliga8-Datensatz und zeigt ua die Tabellenstaumlnde einerbestimmten Saison zu einem bestimmten Spieltag an Des weiteren laumlsst sich mit der Funktion diePlatzierungen der Mannschaften im Saisonverlauf anzeigen Der Standardaufruf lautet
BundesligaTabelle(Saison Spieltag = 1 output = Tabelle)
Hierbei gelten die Parameter
6 Kapitel 545 auf Seite 2367 Kapitel 5732 auf Seite 2468 Kapitel 5732 auf Seite 246
244
Paketinhalt
bull Saison = die gewuumlnschte Saison zB 19761977bull Spieltag = der gewuumlnschte Spieltag zB 14bull output
bull Tabelle = die Tabelle am gewuumlschten Spieltag der gewuumlnschten Saisonbull Platzierung = die Mannschaftsplatzierungen vom 1 bis zum gewuumlnschten Spieltag
Wenn man die Tabelle des 5 Spieltags der Saison 20032004 angezeigt bekommen moumlchte so lautetder Aufruf
BundesligaTabelle(20032004 5)
Moumlchte man sehen welche Platzierungen die teilnehmenden Mannschaften bis zum 8 Spieltagerzielten so lautet der Aufruf
BundesligaTabelle(20062007 8 Platzierung)
BundesligaXML
Diese Funktion benoumltigt den Bundesliga9-Datensatz und erstellt eine XML-Datei der Spielpaa-rungen einer bestimmten bzw aller verfuumlgbaren Saisons Die XML-Datei wird standardmaumlszligig persink()10 in die Datei Bundesligaxml im Arbeitsverzeichnis geschrieben
Der Standardaufruf lautet
BundesligaXML(Datei = Bundesligaxml Saison = all)
Mit dieser Eingabe werden alle verfuumlgbaren Paarungen in die Datei Bundesligaxml imArbeitsverzeichnis geschrieben Moumlchte man lediglich die Saison 19681969 in der DateiSaison1968-69xml abspeichern so lautet der Aufruf
BundesligaXML(Saison1968-69xml 19681969)
Eine mit der Funktion erzeugte XML-Datei aller Paarungen kann hier11 gedownloadet werden
sensspec
Die Funktion sensspec errechnet Sensitivitaumlts- und Spezifitaumltswerte eines Assessmentinstrumentsfuumlr alle moumlglichen Cut-Off-Punkte (vgl Programmierbeispiel 212)
9 Kapitel 5732 auf Seite 24610 httpdewikibooksorgwikiGNU20R3A20sink11 httpwwwprodunisdefTipBundesligaxmlzip12 Kapitel 545 auf Seite 236
245
Das wikibooks-Zusatzpaket
Fuumlr diese Funktion steht der Datensatz cms13 zur Verfuumlgung
data14(cms)sensspec(cms$ascore cms$arisk risk=1)
5732 Datensaumltze
Bundesliga
Der Datensatz Bundesliga enthaumllt alle Paarungen und Ergebnisse der Fuszligball-Bundesliga von1963-2007 Um auf den Datensatz zugreifen zu koumlnnen muss folgender Befehl eingegeben werden
library15(wikibooks)data16(Bundesliga)
Fuumlr diesen Datensatz beinhaltet das wikibooks-Paket die FunktionenBundesligaTabelle17 BundesligaMannschaft18 und BundesligaXML19
cms
Der Datensatz cms enthaumllt 620 Datenfaumllle fuumlr die Funktion sensspec20 Der Datensatz bestehtaus 2 Spalten
ascore - Summenergebnisse eines Assessmentinstruments
arisk - Risikogruppenzuteilung 0 = kein Risiko 1 = Risiko
Die Aktivierung des Datensatzes erfolgt per
data21(cms)
574 Weblinks
bull CRAN-Seite des Pakets22
13 Kapitel 5732 auf Seite 24617 Kapitel 5731 auf Seite 24418 Kapitel 5731 auf Seite 24419 Kapitel 5731 auf Seite 24520 Kapitel 5731 auf Seite 24522 httpwwwcranr-projectorgwebpackageswikibooksindexhtml
246
siehe auch
575 siehe auch
bull Eigene Zusatzpakete erstellen23
23 Kapitel 44 auf Seite 155
247
58 Autoren
Edits User1 Aksum 71
7 Albmont2
1 AndreacuteWilke3
2 Ciciban4
3 Conny5
2 Daniel B6
44 Dirk Huenniger7
2 Don michele kurac8
1 Duschenhocker9
10 Eˆ(nix)10
202 Europol11
6 Faduci12
1 Faron13
1 Fhkade14
1 Flowerfairy15
2 Geekux16
1 Gronau17
43 Hagezussa18
1 HansImGlueck19
1 Hardy4220
3 Jstein21
1 httpdewikibooksorgwindexphptitle=BenutzerAksum_72 httpdewikibooksorgwindexphptitle=BenutzerAlbmont3 httpdewikibooksorgwindexphptitle=BenutzerAndrC3A9Wilke4 httpdewikibooksorgwindexphptitle=BenutzerCiciban5 httpdewikibooksorgwindexphptitle=BenutzerConny6 httpdewikibooksorgwindexphptitle=BenutzerDaniel_B7 httpdewikibooksorgwindexphptitle=BenutzerDirk_Huenniger8 httpdewikibooksorgwindexphptitle=BenutzerDon_michele_kurac9 httpdewikibooksorgwindexphptitle=BenutzerDuschenhocker10 httpdewikibooksorgwindexphptitle=BenutzerE5E28nix2911 httpdewikibooksorgwindexphptitle=BenutzerEuropol12 httpdewikibooksorgwindexphptitle=BenutzerFaduci13 httpdewikibooksorgwindexphptitle=BenutzerFaron14 httpdewikibooksorgwindexphptitle=BenutzerFhkade15 httpdewikibooksorgwindexphptitle=BenutzerFlowerfairy16 httpdewikibooksorgwindexphptitle=BenutzerGeekux17 httpdewikibooksorgwindexphptitle=BenutzerGronau18 httpdewikibooksorgwindexphptitle=BenutzerHagezussa19 httpdewikibooksorgwindexphptitle=BenutzerHansImGlueck20 httpdewikibooksorgwindexphptitle=BenutzerHardy4221 httpdewikibooksorgwindexphptitle=BenutzerJstein
249
Autoren
2 Juetho22
1 MM-Stat23
5 MichaelFrey24
26 MichaelFreyTool25
5 Mickel26
9 Nichtich27
6 Nikocrow28
19 Noresponse29
1 Octanitrocuban30
3 Philipendula31
400 Produnis32
2 Qaswed33
1 Reneacute Schwarz34
1 Salatgurke35
2 Sigbert36
4 Skee37
2 Student38
6 Sutruban39
45 Tfb78540
1 Tomukas41
1 WissensDuumlrster42
22 httpdewikibooksorgwindexphptitle=BenutzerJuetho23 httpdewikibooksorgwindexphptitle=BenutzerMM-Stat24 httpdewikibooksorgwindexphptitle=BenutzerMichaelFrey25 httpdewikibooksorgwindexphptitle=BenutzerMichaelFreyTool26 httpdewikibooksorgwindexphptitle=BenutzerMickel27 httpdewikibooksorgwindexphptitle=BenutzerNichtich28 httpdewikibooksorgwindexphptitle=BenutzerNikocrow29 httpdewikibooksorgwindexphptitle=BenutzerNoresponse30 httpdewikibooksorgwindexphptitle=BenutzerOctanitrocuban31 httpdewikibooksorgwindexphptitle=BenutzerPhilipendula32 httpdewikibooksorgwindexphptitle=BenutzerProdunis33 httpdewikibooksorgwindexphptitle=BenutzerQaswed34 httpdewikibooksorgwindexphptitle=BenutzerRenC3A9_Schwarz35 httpdewikibooksorgwindexphptitle=BenutzerSalatgurke36 httpdewikibooksorgwindexphptitle=BenutzerSigbert37 httpdewikibooksorgwindexphptitle=BenutzerSkee38 httpdewikibooksorgwindexphptitle=BenutzerStudent39 httpdewikibooksorgwindexphptitle=BenutzerSutruban40 httpdewikibooksorgwindexphptitle=BenutzerTfb78541 httpdewikibooksorgwindexphptitle=BenutzerTomukas42 httpdewikibooksorgwindexphptitle=BenutzerWissensDC3BCrster
250
Abbildungsverzeichnis
bull GFDL Gnu Free Documentation License httpwwwgnuorglicensesfdlhtml
bull cc-by-sa-30 Creative Commons Attribution ShareAlike 30 License httpcreativecommonsorglicensesby-sa30
bull cc-by-sa-25 Creative Commons Attribution ShareAlike 25 License httpcreativecommonsorglicensesby-sa25
bull cc-by-sa-20 Creative Commons Attribution ShareAlike 20 License httpcreativecommonsorglicensesby-sa20
bull cc-by-sa-10 Creative Commons Attribution ShareAlike 10 License httpcreativecommonsorglicensesby-sa10
bull cc-by-20 Creative Commons Attribution 20 License httpcreativecommonsorglicensesby20
bull cc-by-20 Creative Commons Attribution 20 License httpcreativecommonsorglicensesby20deeden
bull cc-by-25 Creative Commons Attribution 25 License httpcreativecommonsorglicensesby25deeden
bull cc-by-30 Creative Commons Attribution 30 License httpcreativecommonsorglicensesby30deeden
bull GPL GNU General Public License httpwwwgnuorglicensesgpl-20txt
bull LGPL GNU Lesser General Public License httpwwwgnuorglicenseslgplhtml
bull PD This image is in the public domain
bull ATTR The copyright holder of this file allows anyone to use it for any purpose provided thatthe copyright holder is properly attributed Redistribution derivative work commercial useand all other use is permitted
bull EURO This is the common (reverse) face of a euro coin The copyright on the design ofthe common face of the euro coins belongs to the European Commission Authorised isreproduction in a format without relief (drawings paintings films) provided they are notdetrimental to the image of the euro
bull LFK Lizenz Freie Kunst httpartlibreorglicencelalde
bull CFR Copyright free use
251
Abbildungsverzeichnis
bull EPL Eclipse Public License httpwwweclipseorgorgdocumentsepl-v10php
Copies of the GPL the LGPL as well as a GFDL are included in chapter Licenses43 Please note thatimages in the public domain do not require attribution You may click on the image numbers in thefollowing table to open the webpage of the images in your webbrower
43 Kapitel 59 auf Seite 255
252
Abbildungsverzeichnis
1 GFDL2 Europol44 GFDL3 GFDL4 MyName (Produnis45 (talk46)) PD5 MyName (Produnis47 (talk48)) PD6 MyName (Produnis49 (talk50)) PD7 GFDL8 Thomas Steiner51 cc-by-sa-259 Thomas Steiner52 cc-by-sa-2510 Reneacute Schwarz53 GFDL11 Thomas Steiner54 GFDL12 Produnis55 GFDL
44 httpdewikibooksorgwikiUser3AEuropol45 httpdewikibooksorgwikiUser3AProdunis46 httpdewikibooksorgwikiUser20talk3AProdunis47 httpdewikibooksorgwikiUser3AProdunis48 httpdewikibooksorgwikiUser20talk3AProdunis49 httpdewikibooksorgwikiUser3AProdunis50 httpdewikibooksorgwikiUser20talk3AProdunis51 httpdewikibooksorgwiki3Ade3ABenutzer3AThire52 httpdewikibooksorgwiki3Ade3ABenutzer3AThire53 httpdewikibooksorgwikiUser3ARenE920Schwarz54 httpdewikibooksorgwiki3Ade3ABenutzer3AThire55 httpdewikibooksorgwikiUser3AProdunis
253
59 Licenses
591 GNU GENERAL PUBLIC LICENSEVersion 3 29 June 2007
Copyright copy 2007 Free Software Foundation Inc lthttpfsforggt
Everyone is permitted to copy and distribute verbatim copies of this licensedocument but changing it is not allowed Preamble
The GNU General Public License is a free copyleft license for software andother kinds of works
The licenses for most software and other practical works are designed to ta-ke away your freedom to share and change the works By contrast the GNUGeneral Public License is intended to guarantee your freedom to share andchange all versions of a programndashto make sure it remains free software forall its users We the Free Software Foundation use the GNU General PublicLicense for most of our software it applies also to any other work releasedthis way by its authors You can apply it to your programs too
When we speak of free software we are referring to freedom not price OurGeneral Public Licenses are designed to make sure that you have the free-dom to distribute copies of free software (and charge for them if you wish)that you receive source code or can get it if you want it that you can changethe software or use pieces of it in new free programs and that you know youcan do these things
To protect your rights we need to prevent others from denying you theserights or asking you to surrender the rights Therefore you have certain re-sponsibilities if you distribute copies of the software or if you modify itresponsibilities to respect the freedom of others
For example if you distribute copies of such a program whether gratis or fora fee you must pass on to the recipients the same freedoms that you receivedYou must make sure that they too receive or can get the source code Andyou must show them these terms so they know their rights
Developers that use the GNU GPL protect your rights with two steps (1)assert copyright on the software and (2) offer you this License giving youlegal permission to copy distribute andor modify it
For the developersrsquo and authorsrsquo protection the GPL clearly explains thatthere is no warranty for this free software For both usersrsquo and authorsrsquo sakethe GPL requires that modified versions be marked as changed so that theirproblems will not be attributed erroneously to authors of previous versions
Some devices are designed to deny users access to install or run modified ver-sions of the software inside them although the manufacturer can do so Thisis fundamentally incompatible with the aim of protecting usersrsquo freedom tochange the software The systematic pattern of such abuse occurs in the areaof products for individuals to use which is precisely where it is most unac-ceptable Therefore we have designed this version of the GPL to prohibitthe practice for those products If such problems arise substantially in otherdomains we stand ready to extend this provision to those domains in futureversions of the GPL as needed to protect the freedom of users
Finally every program is threatened constantly by software patents Statesshould not allow patents to restrict development and use of software ongeneral-purpose computers but in those that do we wish to avoid the spe-cial danger that patents applied to a free program could make it effectivelyproprietary To prevent this the GPL assures that patents cannot be used torender the program non-free
The precise terms and conditions for copying distribution and modificationfollow TERMS AND CONDITIONS 0 Definitions
ldquoThis Licenserdquo refers to version 3 of the GNU General Public License
ldquoCopyrightrdquo also means copyright-like laws that apply to other kinds ofworks such as semiconductor masks
ldquoThe Programrdquo refers to any copyrightable work licensed under this LicenseEach licensee is addressed as ldquoyourdquo ldquoLicenseesrdquo and ldquorecipientsrdquo may beindividuals or organizations
To ldquomodifyrdquo a work means to copy from or adapt all or part of the work ina fashion requiring copyright permission other than the making of an exactcopy The resulting work is called a ldquomodified versionrdquo of the earlier workor a work ldquobased onrdquo the earlier work
A ldquocovered workrdquo means either the unmodified Program or a work based onthe Program
To ldquopropagaterdquo a work means to do anything with it that without permis-sion would make you directly or secondarily liable for infringement underapplicable copyright law except executing it on a computer or modifyinga private copy Propagation includes copying distribution (with or withoutmodification) making available to the public and in some countries otheractivities as well
To ldquoconveyrdquo a work means any kind of propagation that enables other partiesto make or receive copies Mere interaction with a user through a computernetwork with no transfer of a copy is not conveying
An interactive user interface displays ldquoAppropriate Legal Noticesrdquo to theextent that it includes a convenient and prominently visible feature that (1)displays an appropriate copyright notice and (2) tells the user that there is nowarranty for the work (except to the extent that warranties are provided) thatlicensees may convey the work under this License and how to view a copyof this License If the interface presents a list of user commands or optionssuch as a menu a prominent item in the list meets this criterion 1 SourceCode
The ldquosource coderdquo for a work means the preferred form of the work formaking modifications to it ldquoObject coderdquo means any non-source form ofa work
A ldquoStandard Interfacerdquo means an interface that either is an official standarddefined by a recognized standards body or in the case of interfaces speci-fied for a particular programming language one that is widely used amongdevelopers working in that language
The ldquoSystem Librariesrdquo of an executable work include anything other thanthe work as a whole that (a) is included in the normal form of packaginga Major Component but which is not part of that Major Component and(b) serves only to enable use of the work with that Major Component or toimplement a Standard Interface for which an implementation is available tothe public in source code form A ldquoMajor Componentrdquo in this context me-ans a major essential component (kernel window system and so on) of thespecific operating system (if any) on which the executable work runs or acompiler used to produce the work or an object code interpreter used to runit
The ldquoCorresponding Sourcerdquo for a work in object code form means all thesource code needed to generate install and (for an executable work) run
the object code and to modify the work including scripts to control tho-se activities However it does not include the workrsquos System Libraries orgeneral-purpose tools or generally available free programs which are usedunmodified in performing those activities but which are not part of the workFor example Corresponding Source includes interface definition files asso-ciated with source files for the work and the source code for shared librariesand dynamically linked subprograms that the work is specifically designedto require such as by intimate data communication or control flow betweenthose subprograms and other parts of the work
The Corresponding Source need not include anything that users can regene-rate automatically from other parts of the Corresponding Source
The Corresponding Source for a work in source code form is that same work2 Basic Permissions
All rights granted under this License are granted for the term of copyrighton the Program and are irrevocable provided the stated conditions are metThis License explicitly affirms your unlimited permission to run the unmo-dified Program The output from running a covered work is covered by thisLicense only if the output given its content constitutes a covered work ThisLicense acknowledges your rights of fair use or other equivalent as providedby copyright law
You may make run and propagate covered works that you do not convey wi-thout conditions so long as your license otherwise remains in force You mayconvey covered works to others for the sole purpose of having them makemodifications exclusively for you or provide you with facilities for runningthose works provided that you comply with the terms of this License inconveying all material for which you do not control copyright Those thusmaking or running the covered works for you must do so exclusively on yourbehalf under your direction and control on terms that prohibit them frommaking any copies of your copyrighted material outside their relationshipwith you
Conveying under any other circumstances is permitted solely under the con-ditions stated below Sublicensing is not allowed section 10 makes it unne-cessary 3 Protecting Usersrsquo Legal Rights From Anti-Circumvention Law
No covered work shall be deemed part of an effective technological measureunder any applicable law fulfilling obligations under article 11 of the WIPOcopyright treaty adopted on 20 December 1996 or similar laws prohibitingor restricting circumvention of such measures
When you convey a covered work you waive any legal power to forbid cir-cumvention of technological measures to the extent such circumvention iseffected by exercising rights under this License with respect to the coveredwork and you disclaim any intention to limit operation or modification of thework as a means of enforcing against the workrsquos users your or third partiesrsquolegal rights to forbid circumvention of technological measures 4 ConveyingVerbatim Copies
You may convey verbatim copies of the Programrsquos source code as you re-ceive it in any medium provided that you conspicuously and appropriatelypublish on each copy an appropriate copyright notice keep intact all noti-ces stating that this License and any non-permissive terms added in accordwith section 7 apply to the code keep intact all notices of the absence ofany warranty and give all recipients a copy of this License along with theProgram
You may charge any price or no price for each copy that you convey and youmay offer support or warranty protection for a fee 5 Conveying ModifiedSource Versions
You may convey a work based on the Program or the modifications to produ-ce it from the Program in the form of source code under the terms of section4 provided that you also meet all of these conditions
a) The work must carry prominent notices stating that you modified it andgiving a relevant date b) The work must carry prominent notices statingthat it is released under this License and any conditions added under section7 This requirement modifies the requirement in section 4 to ldquokeep intactall noticesrdquo c) You must license the entire work as a whole under thisLicense to anyone who comes into possession of a copy This License willtherefore apply along with any applicable section 7 additional terms to thewhole of the work and all its parts regardless of how they are packagedThis License gives no permission to license the work in any other way butit does not invalidate such permission if you have separately received it d) If the work has interactive user interfaces each must display AppropriateLegal Notices however if the Program has interactive interfaces that do notdisplay Appropriate Legal Notices your work need not make them do so
A compilation of a covered work with other separate and independent workswhich are not by their nature extensions of the covered work and which arenot combined with it such as to form a larger program in or on a volume ofa storage or distribution medium is called an ldquoaggregaterdquo if the compilationand its resulting copyright are not used to limit the access or legal rights ofthe compilationrsquos users beyond what the individual works permit Inclusionof a covered work in an aggregate does not cause this License to apply to theother parts of the aggregate 6 Conveying Non-Source Forms
You may convey a covered work in object code form under the terms ofsections 4 and 5 provided that you also convey the machine-readable Corre-sponding Source under the terms of this License in one of these ways
a) Convey the object code in or embodied in a physical product (includinga physical distribution medium) accompanied by the Corresponding Sourcefixed on a durable physical medium customarily used for software interch-ange b) Convey the object code in or embodied in a physical product(including a physical distribution medium) accompanied by a written offervalid for at least three years and valid for as long as you offer spare parts orcustomer support for that product model to give anyone who possesses theobject code either (1) a copy of the Corresponding Source for all the softwarein the product that is covered by this License on a durable physical mediumcustomarily used for software interchange for a price no more than yourreasonable cost of physically performing this conveying of source or (2) ac-cess to copy the Corresponding Source from a network server at no charge c) Convey individual copies of the object code with a copy of the writtenoffer to provide the Corresponding Source This alternative is allowed onlyoccasionally and noncommercially and only if you received the object codewith such an offer in accord with subsection 6b d) Convey the object codeby offering access from a designated place (gratis or for a charge) and of-fer equivalent access to the Corresponding Source in the same way throughthe same place at no further charge You need not require recipients to copythe Corresponding Source along with the object code If the place to copythe object code is a network server the Corresponding Source may be on adifferent server (operated by you or a third party) that supports equivalentcopying facilities provided you maintain clear directions next to the objectcode saying where to find the Corresponding Source Regardless of what ser-ver hosts the Corresponding Source you remain obligated to ensure that itis available for as long as needed to satisfy these requirements e) Conveythe object code using peer-to-peer transmission provided you inform otherpeers where the object code and Corresponding Source of the work are beingoffered to the general public at no charge under subsection 6d
A separable portion of the object code whose source code is excluded fromthe Corresponding Source as a System Library need not be included in con-veying the object code work
A ldquoUser Productrdquo is either (1) a ldquoconsumer productrdquo which means any tan-gible personal property which is normally used for personal family or hou-sehold purposes or (2) anything designed or sold for incorporation into adwelling In determining whether a product is a consumer product doubtfulcases shall be resolved in favor of coverage For a particular product receivedby a particular user ldquonormally usedrdquo refers to a typical or common use ofthat class of product regardless of the status of the particular user or of theway in which the particular user actually uses or expects or is expected touse the product A product is a consumer product regardless of whether theproduct has substantial commercial industrial or non-consumer uses unlesssuch uses represent the only significant mode of use of the product
ldquoInstallation Informationrdquo for a User Product means any methods procedu-res authorization keys or other information required to install and executemodified versions of a covered work in that User Product from a modifiedversion of its Corresponding Source The information must suffice to ensu-re that the continued functioning of the modified object code is in no caseprevented or interfered with solely because modification has been made
If you convey an object code work under this section in or with or specifical-ly for use in a User Product and the conveying occurs as part of a transactionin which the right of possession and use of the User Product is transferred tothe recipient in perpetuity or for a fixed term (regardless of how the transac-tion is characterized) the Corresponding Source conveyed under this sectionmust be accompanied by the Installation Information But this requirementdoes not apply if neither you nor any third party retains the ability to installmodified object code on the User Product (for example the work has beeninstalled in ROM)
The requirement to provide Installation Information does not include a re-quirement to continue to provide support service warranty or updates for awork that has been modified or installed by the recipient or for the User Pro-duct in which it has been modified or installed Access to a network may bedenied when the modification itself materially and adversely affects the ope-ration of the network or violates the rules and protocols for communicationacross the network
Corresponding Source conveyed and Installation Information provided inaccord with this section must be in a format that is publicly documented(and with an implementation available to the public in source code form)and must require no special password or key for unpacking reading or copy-ing 7 Additional Terms
ldquoAdditional permissionsrdquo are terms that supplement the terms of this Licenseby making exceptions from one or more of its conditions Additional permis-sions that are applicable to the entire Program shall be treated as though theywere included in this License to the extent that they are valid under applica-ble law If additional permissions apply only to part of the Program that partmay be used separately under those permissions but the entire Program re-mains governed by this License without regard to the additional permissions
When you convey a copy of a covered work you may at your option removeany additional permissions from that copy or from any part of it (Addi-tional permissions may be written to require their own removal in certaincases when you modify the work) You may place additional permissions onmaterial added by you to a covered work for which you have or can giveappropriate copyright permission
Notwithstanding any other provision of this License for material you addto a covered work you may (if authorized by the copyright holders of thatmaterial) supplement the terms of this License with terms
a) Disclaiming warranty or limiting liability differently from the terms ofsections 15 and 16 of this License or b) Requiring preservation of specifiedreasonable legal notices or author attributions in that material or in the Ap-propriate Legal Notices displayed by works containing it or c) Prohibitingmisrepresentation of the origin of that material or requiring that modifiedversions of such material be marked in reasonable ways as different from theoriginal version or d) Limiting the use for publicity purposes of names oflicensors or authors of the material or e) Declining to grant rights undertrademark law for use of some trade names trademarks or service marksor f) Requiring indemnification of licensors and authors of that materialby anyone who conveys the material (or modified versions of it) with con-tractual assumptions of liability to the recipient for any liability that thesecontractual assumptions directly impose on those licensors and authors
All other non-permissive additional terms are considered ldquofurther restric-tionsrdquo within the meaning of section 10 If the Program as you received itor any part of it contains a notice stating that it is governed by this Licen-se along with a term that is a further restriction you may remove that termIf a license document contains a further restriction but permits relicensingor conveying under this License you may add to a covered work materialgoverned by the terms of that license document provided that the furtherrestriction does not survive such relicensing or conveying
If you add terms to a covered work in accord with this section you mustplace in the relevant source files a statement of the additional terms thatapply to those files or a notice indicating where to find the applicable terms
Additional terms permissive or non-permissive may be stated in the form ofa separately written license or stated as exceptions the above requirementsapply either way 8 Termination
You may not propagate or modify a covered work except as expressly provi-ded under this License Any attempt otherwise to propagate or modify it isvoid and will automatically terminate your rights under this License (inclu-ding any patent licenses granted under the third paragraph of section 11)
However if you cease all violation of this License then your license froma particular copyright holder is reinstated (a) provisionally unless and untilthe copyright holder explicitly and finally terminates your license and (b)permanently if the copyright holder fails to notify you of the violation bysome reasonable means prior to 60 days after the cessation
Moreover your license from a particular copyright holder is reinstated per-manently if the copyright holder notifies you of the violation by some rea-sonable means this is the first time you have received notice of violationof this License (for any work) from that copyright holder and you cure theviolation prior to 30 days after your receipt of the notice
Termination of your rights under this section does not terminate the licensesof parties who have received copies or rights from you under this LicenseIf your rights have been terminated and not permanently reinstated you donot qualify to receive new licenses for the same material under section 10 9Acceptance Not Required for Having Copies
You are not required to accept this License in order to receive or run a copyof the Program Ancillary propagation of a covered work occurring solely asa consequence of using peer-to-peer transmission to receive a copy likewisedoes not require acceptance However nothing other than this License grants
you permission to propagate or modify any covered work These actions in-fringe copyright if you do not accept this License Therefore by modifyingor propagating a covered work you indicate your acceptance of this Licenseto do so 10 Automatic Licensing of Downstream Recipients
Each time you convey a covered work the recipient automatically receives alicense from the original licensors to run modify and propagate that worksubject to this License You are not responsible for enforcing compliance bythird parties with this License
An ldquoentity transactionrdquo is a transaction transferring control of an organizati-on or substantially all assets of one or subdividing an organization or mer-ging organizations If propagation of a covered work results from an entitytransaction each party to that transaction who receives a copy of the workalso receives whatever licenses to the work the partyrsquos predecessor in interesthad or could give under the previous paragraph plus a right to possession ofthe Corresponding Source of the work from the predecessor in interest if thepredecessor has it or can get it with reasonable efforts
You may not impose any further restrictions on the exercise of the rightsgranted or affirmed under this License For example you may not impose alicense fee royalty or other charge for exercise of rights granted under thisLicense and you may not initiate litigation (including a cross-claim or coun-terclaim in a lawsuit) alleging that any patent claim is infringed by makingusing selling offering for sale or importing the Program or any portion ofit 11 Patents
A ldquocontributorrdquo is a copyright holder who authorizes use under this Licenseof the Program or a work on which the Program is based The work thuslicensed is called the contributorrsquos ldquocontributor versionrdquo
A contributorrsquos ldquoessential patent claimsrdquo are all patent claims owned or con-trolled by the contributor whether already acquired or hereafter acquiredthat would be infringed by some manner permitted by this License of ma-king using or selling its contributor version but do not include claims thatwould be infringed only as a consequence of further modification of the cont-ributor version For purposes of this definition ldquocontrolrdquo includes the rightto grant patent sublicenses in a manner consistent with the requirements ofthis License
Each contributor grants you a non-exclusive worldwide royalty-free patentlicense under the contributorrsquos essential patent claims to make use sell of-fer for sale import and otherwise run modify and propagate the contents ofits contributor version
In the following three paragraphs a ldquopatent licenserdquo is any express agree-ment or commitment however denominated not to enforce a patent (such asan express permission to practice a patent or covenant not to sue for patentinfringement) To ldquograntrdquo such a patent license to a party means to makesuch an agreement or commitment not to enforce a patent against the party
If you convey a covered work knowingly relying on a patent license and theCorresponding Source of the work is not available for anyone to copy freeof charge and under the terms of this License through a publicly availablenetwork server or other readily accessible means then you must either (1)cause the Corresponding Source to be so available or (2) arrange to depriveyourself of the benefit of the patent license for this particular work or (3) ar-range in a manner consistent with the requirements of this License to extendthe patent license to downstream recipients ldquoKnowingly relyingrdquo means youhave actual knowledge that but for the patent license your conveying the co-vered work in a country or your recipientrsquos use of the covered work in acountry would infringe one or more identifiable patents in that country thatyou have reason to believe are valid
If pursuant to or in connection with a single transaction or arrangement youconvey or propagate by procuring conveyance of a covered work and granta patent license to some of the parties receiving the covered work authorizingthem to use propagate modify or convey a specific copy of the covered workthen the patent license you grant is automatically extended to all recipientsof the covered work and works based on it
A patent license is ldquodiscriminatoryrdquo if it does not include within the scope ofits coverage prohibits the exercise of or is conditioned on the non-exerciseof one or more of the rights that are specifically granted under this LicenseYou may not convey a covered work if you are a party to an arrangementwith a third party that is in the business of distributing software under whichyou make payment to the third party based on the extent of your activity ofconveying the work and under which the third party grants to any of the par-ties who would receive the covered work from you a discriminatory patentlicense (a) in connection with copies of the covered work conveyed by you(or copies made from those copies) or (b) primarily for and in connectionwith specific products or compilations that contain the covered work unlessyou entered into that arrangement or that patent license was granted priorto 28 March 2007
Nothing in this License shall be construed as excluding or limiting any im-plied license or other defenses to infringement that may otherwise be avail-able to you under applicable patent law 12 No Surrender of Othersrsquo Free-dom
If conditions are imposed on you (whether by court order agreement or other-wise) that contradict the conditions of this License they do not excuse youfrom the conditions of this License If you cannot convey a covered workso as to satisfy simultaneously your obligations under this License and anyother pertinent obligations then as a consequence you may not convey it atall For example if you agree to terms that obligate you to collect a royaltyfor further conveying from those to whom you convey the Program the onlyway you could satisfy both those terms and this License would be to refrainentirely from conveying the Program 13 Use with the GNU Affero GeneralPublic License
Notwithstanding any other provision of this License you have permission tolink or combine any covered work with a work licensed under version 3 ofthe GNU Affero General Public License into a single combined work and toconvey the resulting work The terms of this License will continue to apply tothe part which is the covered work but the special requirements of the GNUAffero General Public License section 13 concerning interaction through anetwork will apply to the combination as such 14 Revised Versions of thisLicense
The Free Software Foundation may publish revised andor new versions ofthe GNU General Public License from time to time Such new versions willbe similar in spirit to the present version but may differ in detail to addressnew problems or concerns
Each version is given a distinguishing version number If the Program speci-fies that a certain numbered version of the GNU General Public License ldquoorany later versionrdquo applies to it you have the option of following the termsand conditions either of that numbered version or of any later version pu-blished by the Free Software Foundation If the Program does not specify aversion number of the GNU General Public License you may choose anyversion ever published by the Free Software Foundation
If the Program specifies that a proxy can decide which future versions of theGNU General Public License can be used that proxyrsquos public statement of
255
Licenses
acceptance of a version permanently authorizes you to choose that versionfor the Program
Later license versions may give you additional or different permissionsHowever no additional obligations are imposed on any author or copyrightholder as a result of your choosing to follow a later version 15 Disclaimerof Warranty
THERE IS NO WARRANTY FOR THE PROGRAM TO THE EXTENTPERMITTED BY APPLICABLE LAW EXCEPT WHEN OTHERWISESTATED IN WRITING THE COPYRIGHT HOLDERS ANDOR OTHERPARTIES PROVIDE THE PROGRAM ldquoAS ISrdquo WITHOUT WARRANTYOF ANY KIND EITHER EXPRESSED OR IMPLIED INCLUDING BUTNOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTA-BILITY AND FITNESS FOR A PARTICULAR PURPOSE THE ENTI-RE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PRO-GRAM IS WITH YOU SHOULD THE PROGRAM PROVE DEFECTIVEYOU ASSUME THE COST OF ALL NECESSARY SERVICING REPAIROR CORRECTION 16 Limitation of Liability
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW ORAGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER ORANY OTHER PARTY WHO MODIFIES ANDOR CONVEYS THE PRO-
GRAM AS PERMITTED ABOVE BE LIABLE TO YOU FOR DA-MAGES INCLUDING ANY GENERAL SPECIAL INCIDENTAL ORCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INA-BILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITEDTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE ORLOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILUREOF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS)EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OFTHE POSSIBILITY OF SUCH DAMAGES 17 Interpretation of Sections15 and 16
If the disclaimer of warranty and limitation of liability provided above can-not be given local legal effect according to their terms reviewing courts shallapply local law that most closely approximates an absolute waiver of all civilliability in connection with the Program unless a warranty or assumption ofliability accompanies a copy of the Program in return for a fee
END OF TERMS AND CONDITIONS How to Apply These Terms to YourNew Programs
If you develop a new program and you want it to be of the greatest possibleuse to the public the best way to achieve this is to make it free softwarewhich everyone can redistribute and change under these terms
To do so attach the following notices to the program It is safest to attachthem to the start of each source file to most effectively state the exclusion ofwarranty and each file should have at least the ldquocopyrightrdquo line and a pointerto where the full notice is found
ltone line to give the programrsquos name and a brief idea of what it doesgt Co-pyright (C) ltyeargt ltname of authorgt
This program is free software you can redistribute it andor modify it underthe terms of the GNU General Public License as published by the Free Soft-ware Foundation either version 3 of the License or (at your option) any laterversion
This program is distributed in the hope that it will be useful but WITHOUTANY WARRANTY without even the implied warranty of MERCHANTA-BILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU Ge-neral Public License for more details
You should have received a copy of the GNU General Public License alongwith this program If not see lthttpwwwgnuorglicensesgt
Also add information on how to contact you by electronic and paper mail
If the program does terminal interaction make it output a short notice likethis when it starts in an interactive mode
ltprogramgt Copyright (C) ltyeargt ltname of authorgt This program comeswith ABSOLUTELY NO WARRANTY for details type lsquoshow wrsquo This isfree software and you are welcome to redistribute it under certain conditi-ons type lsquoshow crsquo for details
The hypothetical commands lsquoshow wrsquo and lsquoshow crsquo should show the appro-priate parts of the General Public License Of course your programrsquos com-mands might be different for a GUI interface you would use an ldquoabout boxrdquo
You should also get your employer (if you work as a programmer) or schoolif any to sign a ldquocopyright disclaimerrdquo for the program if necessary Formore information on this and how to apply and follow the GNU GPL seelthttpwwwgnuorglicensesgt
The GNU General Public License does not permit incorporating your pro-gram into proprietary programs If your program is a subroutine libraryyou may consider it more useful to permit linking proprietary applicati-ons with the library If this is what you want to do use the GNU Les-ser General Public License instead of this License But first please readlthttpwwwgnuorgphilosophywhy-not-lgplhtmlgt
592 GNU Free Documentation LicenseVersion 13 3 November 2008
Copyright copy 2000 2001 2002 2007 2008 Free Software Foundation Inclthttpfsforggt
Everyone is permitted to copy and distribute verbatim copies of this licensedocument but changing it is not allowed 0 PREAMBLE
The purpose of this License is to make a manual textbook or other func-tional and useful document freeiumln the sense of freedom to assure everyonethe effective freedom to copy and redistribute it with or without modifyingit either commercially or noncommercially Secondarily this License preser-ves for the author and publisher a way to get credit for their work while notbeing considered responsible for modifications made by others
This License is a kind of copyleft which means that derivative works ofthe document must themselves be free in the same sense It complements theGNU General Public License which is a copyleft license designed for freesoftware
We have designed this License in order to use it for manuals for free softwarebecause free software needs free documentation a free program should comewith manuals providing the same freedoms that the software does But thisLicense is not limited to software manuals it can be used for any textualwork regardless of subject matter or whether it is published as a printedbook We recommend this License principally for works whose purpose isinstruction or reference 1 APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work in any medium that conta-ins a notice placed by the copyright holder saying it can be distributed underthe terms of this License Such a notice grants a world-wide royalty-freelicense unlimited in duration to use that work under the conditions statedherein The Document below refers to any such manual or work Anymember of the public is a licensee and is addressed as you You acceptthe license if you copy modify or distribute the work in a way requiringpermission under copyright law
A Modified Versionoumlf the Document means any work containing the Docu-ment or a portion of it either copied verbatim or with modifications andortranslated into another language
A SSecondary Sectioniumls a named appendix or a front-matter section of theDocument that deals exclusively with the relationship of the publishers orauthors of the Document to the Documentrsquos overall subject (or to related mat-ters) and contains nothing that could fall directly within that overall subject(Thus if the Document is in part a textbook of mathematics a Secondary Sec-tion may not explain any mathematics) The relationship could be a matterof historical connection with the subject or with related matters or of legalcommercial philosophical ethical or political position regarding them
The Iumlnvariant Sectionsaumlre certain Secondary Sections whose titles are desi-gnated as being those of Invariant Sections in the notice that says that theDocument is released under this License If a section does not fit the abovedefinition of Secondary then it is not allowed to be designated as InvariantThe Document may contain zero Invariant Sections If the Document doesnot identify any Invariant Sections then there are none
The Cover Textsaumlre certain short passages of text that are listed as Front-Cover Texts or Back-Cover Texts in the notice that says that the Documentis released under this License A Front-Cover Text may be at most 5 wordsand a Back-Cover Text may be at most 25 words
A Transparentcopy of the Document means a machine-readable copy re-presented in a format whose specification is available to the general publicthat is suitable for revising the document straightforwardly with generic texteditors or (for images composed of pixels) generic paint programs or (fordrawings) some widely available drawing editor and that is suitable for inputto text formatters or for automatic translation to a variety of formats suitablefor input to text formatters A copy made in an otherwise Transparent fileformat whose markup or absence of markup has been arranged to thwart ordiscourage subsequent modification by readers is not Transparent An imageformat is not Transparent if used for any substantial amount of text A copythat is not Transparentiumls called Oumlpaque
Examples of suitable formats for Transparent copies include plain ASCII wi-thout markup Texinfo input format LaTeX input format SGML or XMLusing a publicly available DTD and standard-conforming simple HTMLPostScript or PDF designed for human modification Examples of transpa-rent image formats include PNG XCF and JPG Opaque formats includeproprietary formats that can be read and edited only by proprietary word pro-cessors SGML or XML for which the DTD andor processing tools are notgenerally available and the machine-generated HTML PostScript or PDFproduced by some word processors for output purposes only
The Title Pagemeans for a printed book the title page itself plus such fol-lowing pages as are needed to hold legibly the material this License requiresto appear in the title page For works in formats which do not have any titlepage as such Title Pagemeans the text near the most prominent appearanceof the workrsquos title preceding the beginning of the body of the text
The publishermeans any person or entity that distributes copies of the Do-cument to the public
A section Eumlntitled XYZmeans a named subunit of the Document whose titleeither is precisely XYZ or contains XYZ in parentheses following text that
translates XYZ in another language (Here XYZ stands for a specific sectionname mentioned below such as Aumlcknowledgements Dedications Eumlndor-sements or History) To Preserve the Titleoumlf such a section when youmodify the Document means that it remains a section Eumlntitled XYZaumlccor-ding to this definition
The Document may include Warranty Disclaimers next to the notice whichstates that this License applies to the Document These Warranty Disclai-mers are considered to be included by reference in this License but onlyas regards disclaiming warranties any other implication that these Warran-ty Disclaimers may have is void and has no effect on the meaning of thisLicense 2 VERBATIM COPYING
You may copy and distribute the Document in any medium either commer-cially or noncommercially provided that this License the copyright noticesand the license notice saying this License applies to the Document are repro-duced in all copies and that you add no other conditions whatsoever to thoseof this License You may not use technical measures to obstruct or controlthe reading or further copying of the copies you make or distribute Howeveryou may accept compensation in exchange for copies If you distribute a lar-ge enough number of copies you must also follow the conditions in section3
You may also lend copies under the same conditions stated above and youmay publicly display copies 3 COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printedcovers) of the Document numbering more than 100 and the Documentrsquos li-cense notice requires Cover Texts you must enclose the copies in covers thatcarry clearly and legibly all these Cover Texts Front-Cover Texts on thefront cover and Back-Cover Texts on the back cover Both covers must alsoclearly and legibly identify you as the publisher of these copies The frontcover must present the full title with all words of the title equally prominentand visible You may add other material on the covers in addition Copyingwith changes limited to the covers as long as they preserve the title of theDocument and satisfy these conditions can be treated as verbatim copyingin other respects
If the required texts for either cover are too voluminous to fit legibly youshould put the first ones listed (as many as fit reasonably) on the actual coverand continue the rest onto adjacent pages
If you publish or distribute Opaque copies of the Document numberingmore than 100 you must either include a machine-readable Transparentcopy along with each Opaque copy or state in or with each Opaque copya computer-network location from which the general network-using publichas access to download using public-standard network protocols a completeTransparent copy of the Document free of added material If you use thelatter option you must take reasonably prudent steps when you begin dis-tribution of Opaque copies in quantity to ensure that this Transparent copywill remain thus accessible at the stated location until at least one year afterthe last time you distribute an Opaque copy (directly or through your agentsor retailers) of that edition to the public
It is requested but not required that you contact the authors of the Documentwell before redistributing any large number of copies to give them a chanceto provide you with an updated version of the Document 4 MODIFICATI-ONS
You may copy and distribute a Modified Version of the Document under theconditions of sections 2 and 3 above provided that you release the Modi-fied Version under precisely this License with the Modified Version fillingthe role of the Document thus licensing distribution and modification of theModified Version to whoever possesses a copy of it In addition you mustdo these things in the Modified Version
A Use in the Title Page (and on the covers if any) a title distinct from thatof the Document and from those of previous versions (which should if therewere any be listed in the History section of the Document) You may use thesame title as a previous version if the original publisher of that version givespermission B List on the Title Page as authors one or more persons or en-tities responsible for authorship of the modifications in the Modified Versiontogether with at least five of the principal authors of the Document (all of itsprincipal authors if it has fewer than five) unless they release you from thisrequirement C State on the Title page the name of the publisher of theModified Version as the publisher D Preserve all the copyright noticesof the Document E Add an appropriate copyright notice for your modi-fications adjacent to the other copyright notices F Include immediatelyafter the copyright notices a license notice giving the public permission touse the Modified Version under the terms of this License in the form shownin the Addendum below G Preserve in that license notice the full lists ofInvariant Sections and required Cover Texts given in the Documentrsquos licensenotice H Include an unaltered copy of this License I Preserve the sec-tion Entitled History Preserve its Title and add to it an item stating at leastthe title year new authors and publisher of the Modified Version as given onthe Title Page If there is no section Entitled Historyiumln the Document createone stating the title year authors and publisher of the Document as givenon its Title Page then add an item describing the Modified Version as statedin the previous sentence J Preserve the network location if any givenin the Document for public access to a Transparent copy of the Documentand likewise the network locations given in the Document for previous ver-sions it was based on These may be placed in the Historyszligection You mayomit a network location for a work that was published at least four yearsbefore the Document itself or if the original publisher of the version it re-fers to gives permission K For any section Entitled AumlcknowledgementsoumlrDedications Preserve the Title of the section and preserve in the section
all the substance and tone of each of the contributor acknowledgements an-dor dedications given therein L Preserve all the Invariant Sections ofthe Document unaltered in their text and in their titles Section numbers orthe equivalent are not considered part of the section titles M Delete anysection Entitled Eumlndorsements Such a section may not be included in theModified Version N Do not retitle any existing section to be Entitled Eumln-dorsementsoumlr to conflict in title with any Invariant Section O Preserve anyWarranty Disclaimers
If the Modified Version includes new front-matter sections or appendicesthat qualify as Secondary Sections and contain no material copied from theDocument you may at your option designate some or all of these sectionsas invariant To do this add their titles to the list of Invariant Sections inthe Modified Versionrsquos license notice These titles must be distinct from anyother section titles
You may add a section Entitled Eumlndorsements provided it contains nothingbut endorsements of your Modified Version by various partiesmdashfor examplestatements of peer review or that the text has been approved by an organizat-ion as the authoritative definition of a standard
You may add a passage of up to five words as a Front-Cover Text and a pas-sage of up to 25 words as a Back-Cover Text to the end of the list of CoverTexts in the Modified Version Only one passage of Front-Cover Text andone of Back-Cover Text may be added by (or through arrangements madeby) any one entity If the Document already includes a cover text for thesame cover previously added by you or by arrangement made by the sameentity you are acting on behalf of you may not add another but you mayreplace the old one on explicit permission from the previous publisher thatadded the old one
The author(s) and publisher(s) of the Document do not by this License givepermission to use their names for publicity for or to assert or imply endorse-ment of any Modified Version 5 COMBINING DOCUMENTS
You may combine the Document with other documents released under thisLicense under the terms defined in section 4 above for modified versionsprovided that you include in the combination all of the Invariant Sections ofall of the original documents unmodified and list them all as Invariant Sec-tions of your combined work in its license notice and that you preserve alltheir Warranty Disclaimers
The combined work need only contain one copy of this License and multipleidentical Invariant Sections may be replaced with a single copy If there aremultiple Invariant Sections with the same name but different contents makethe title of each such section unique by adding at the end of it in parenthesesthe name of the original author or publisher of that section if known or elsea unique number Make the same adjustment to the section titles in the list ofInvariant Sections in the license notice of the combined work
In the combination you must combine any sections Entitled Historyiumln thevarious original documents forming one section Entitled History likewisecombine any sections Entitled Aumlcknowledgements and any sections Entit-led Dedications You must delete all sections Entitled Eumlndorsements 6COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documentsreleased under this License and replace the individual copies of this Licensein the various documents with a single copy that is included in the collectionprovided that you follow the rules of this License for verbatim copying ofeach of the documents in all other respects
You may extract a single document from such a collection and distribute itindividually under this License provided you insert a copy of this Licenseinto the extracted document and follow this License in all other respectsregarding verbatim copying of that document 7 AGGREGATION WITHINDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate and in-dependent documents or works in or on a volume of a storage or distributionmedium is called an aumlggregateiumlf the copyright resulting from the compilati-on is not used to limit the legal rights of the compilationrsquos users beyond whatthe individual works permit When the Document is included in an aggregatethis License does not apply to the other works in the aggregate which are notthemselves derivative works of the Document
If the Cover Text requirement of section 3 is applicable to these copies ofthe Document then if the Document is less than one half of the entire ag-gregate the Documentrsquos Cover Texts may be placed on covers that bracketthe Document within the aggregate or the electronic equivalent of covers ifthe Document is in electronic form Otherwise they must appear on printedcovers that bracket the whole aggregate 8 TRANSLATION
Translation is considered a kind of modification so you may distribute trans-lations of the Document under the terms of section 4 Replacing InvariantSections with translations requires special permission from their copyrightholders but you may include translations of some or all Invariant Sections inaddition to the original versions of these Invariant Sections You may inclu-de a translation of this License and all the license notices in the Documentand any Warranty Disclaimers provided that you also include the originalEnglish version of this License and the original versions of those notices anddisclaimers In case of a disagreement between the translation and the origi-nal version of this License or a notice or disclaimer the original version willprevail
If a section in the Document is Entitled Aumlcknowledgements Dedicationsor History the requirement (section 4) to Preserve its Title (section 1) willtypically require changing the actual title 9 TERMINATION
You may not copy modify sublicense or distribute the Document except asexpressly provided under this License Any attempt otherwise to copy modi-fy sublicense or distribute it is void and will automatically terminate yourrights under this License
However if you cease all violation of this License then your license froma particular copyright holder is reinstated (a) provisionally unless and untilthe copyright holder explicitly and finally terminates your license and (b)permanently if the copyright holder fails to notify you of the violation bysome reasonable means prior to 60 days after the cessation
Moreover your license from a particular copyright holder is reinstated per-manently if the copyright holder notifies you of the violation by some rea-sonable means this is the first time you have received notice of violationof this License (for any work) from that copyright holder and you cure theviolation prior to 30 days after your receipt of the notice
Termination of your rights under this section does not terminate the licensesof parties who have received copies or rights from you under this License Ifyour rights have been terminated and not permanently reinstated receipt of acopy of some or all of the same material does not give you any rights to useit 10 FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new revised versions of theGNU Free Documentation License from time to time Such new versionswill be similar in spirit to the present version but may differ in detail toaddress new problems or concerns See httpwwwgnuorgcopyleft
Each version of the License is given a distinguishing version number If theDocument specifies that a particular numbered version of this License oumlr anylater versionaumlpplies to it you have the option of following the terms and con-ditions either of that specified version or of any later version that has beenpublished (not as a draft) by the Free Software Foundation If the Documentdoes not specify a version number of this License you may choose any ver-sion ever published (not as a draft) by the Free Software Foundation If theDocument specifies that a proxy can decide which future versions of thisLicense can be used that proxyrsquos public statement of acceptance of a versi-on permanently authorizes you to choose that version for the Document 11RELICENSING
Massive Multiauthor Collaboration Site(or MMC Site) means any WorldWide Web server that publishes copyrightable works and also provides pro-minent facilities for anybody to edit those works A public wiki that anybodycan edit is an example of such a server A Massive Multiauthor Collaborati-on(or MMC) contained in the site means any set of copyrightable worksthus published on the MMC site
CC-BY-SAmeans the Creative Commons Attribution-Share Alike 30 li-cense published by Creative Commons Corporation a not-for-profit corpora-tion with a principal place of business in San Francisco California as well asfuture copyleft versions of that license published by that same organization
Iumlncorporatemeans to publish or republish a Document in whole or in partas part of another Document
An MMC is eumlligible for relicensingiumlf it is licensed under this License and ifall works that were first published under this License somewhere other thanthis MMC and subsequently incorporated in whole or in part into the MMC(1) had no cover texts or invariant sections and (2) were thus incorporatedprior to November 1 2008
The operator of an MMC Site may republish an MMC contained in the siteunder CC-BY-SA on the same site at any time before August 1 2009 pro-vided the MMC is eligible for relicensing ADDENDUM How to use thisLicense for your documents
To use this License in a document you have written include a copy of theLicense in the document and put the following copyright and license noticesjust after the title page
Copyright (C) YEAR YOUR NAME Permission is granted to copy distri-bute andor modify this document under the terms of the GNU Free Docu-mentation License Version 13 or any later version published by the FreeSoftware Foundation with no Invariant Sections no Front-Cover Texts andno Back-Cover Texts A copy of the license is included in the section entitledGNU Free Documentation License
If you have Invariant Sections Front-Cover Texts and Back-Cover Texts re-place the with Textsline with this
with the Invariant Sections being LIST THEIR TITLES with the Front-Cover Texts being LIST and with the Back-Cover Texts being LIST
If you have Invariant Sections without Cover Texts or some other combina-tion of the three merge those two alternatives to suit the situation
If your document contains nontrivial examples of program code we recom-mend releasing these examples in parallel under your choice of free softwarelicense such as the GNU General Public License to permit their use in freesoftware
593 GNU Lesser General Public LicenseGNU LESSER GENERAL PUBLIC LICENSE
Version 3 29 June 2007
Copyright copy 2007 Free Software Foundation Inc lthttpfsforggt
Everyone is permitted to copy and distribute verbatim copies of this licensedocument but changing it is not allowed
This version of the GNU Lesser General Public License incorporates theterms and conditions of version 3 of the GNU General Public License sup-plemented by the additional permissions listed below 0 Additional Definiti-ons
As used herein ldquothis Licenserdquo refers to version 3 of the GNU Lesser GeneralPublic License and the ldquoGNU GPLrdquo refers to version 3 of the GNU GeneralPublic License
ldquoThe Libraryrdquo refers to a covered work governed by this License other thanan Application or a Combined Work as defined below
An ldquoApplicationrdquo is any work that makes use of an interface provided by theLibrary but which is not otherwise based on the Library Defining a subclassof a class defined by the Library is deemed a mode of using an interfaceprovided by the Library
A ldquoCombined Workrdquo is a work produced by combining or linking an Appli-cation with the Library The particular version of the Library with which theCombined Work was made is also called the ldquoLinked Versionrdquo
The ldquoMinimal Corresponding Sourcerdquo for a Combined Work means the Cor-responding Source for the Combined Work excluding any source code forportions of the Combined Work that considered in isolation are based onthe Application and not on the Linked Version
256
GNU Lesser General Public License
The ldquoCorresponding Application Coderdquo for a Combined Work means theobject code andor source code for the Application including any data andutility programs needed for reproducing the Combined Work from the Appli-cation but excluding the System Libraries of the Combined Work 1 Excep-tion to Section 3 of the GNU GPL
You may convey a covered work under sections 3 and 4 of this License wi-thout being bound by section 3 of the GNU GPL 2 Conveying ModifiedVersions
If you modify a copy of the Library and in your modifications a facilityrefers to a function or data to be supplied by an Application that uses thefacility (other than as an argument passed when the facility is invoked) thenyou may convey a copy of the modified version
a) under this License provided that you make a good faith effort to ensu-re that in the event an Application does not supply the function or data thefacility still operates and performs whatever part of its purpose remains mea-ningful or b) under the GNU GPL with none of the additional permissionsof this License applicable to that copy
3 Object Code Incorporating Material from Library Header Files
The object code form of an Application may incorporate material from a hea-der file that is part of the Library You may convey such object code under
terms of your choice provided that if the incorporated material is not limi-ted to numerical parameters data structure layouts and accessors or smallmacros inline functions and templates (ten or fewer lines in length) you doboth of the following
a) Give prominent notice with each copy of the object code that the Libraryis used in it and that the Library and its use are covered by this License b)Accompany the object code with a copy of the GNU GPL and this licensedocument
4 Combined Works
You may convey a Combined Work under terms of your choice that takentogether effectively do not restrict modification of the portions of the Libra-ry contained in the Combined Work and reverse engineering for debuggingsuch modifications if you also do each of the following
a) Give prominent notice with each copy of the Combined Work that theLibrary is used in it and that the Library and its use are covered by this Li-cense b) Accompany the Combined Work with a copy of the GNU GPLand this license document c) For a Combined Work that displays copy-right notices during execution include the copyright notice for the Libraryamong these notices as well as a reference directing the user to the copiesof the GNU GPL and this license document d) Do one of the followingo 0) Convey the Minimal Corresponding Source under the terms of this Li-cense and the Corresponding Application Code in a form suitable for and
under terms that permit the user to recombine or relink the Application witha modified version of the Linked Version to produce a modified CombinedWork in the manner specified by section 6 of the GNU GPL for conveyingCorresponding Source o 1) Use a suitable shared library mechanism for lin-king with the Library A suitable mechanism is one that (a) uses at run timea copy of the Library already present on the userrsquos computer system and (b)will operate properly with a modified version of the Library that is interface-compatible with the Linked Version e) Provide Installation Informationbut only if you would otherwise be required to provide such informationunder section 6 of the GNU GPL and only to the extent that such informa-tion is necessary to install and execute a modified version of the CombinedWork produced by recombining or relinking the Application with a modi-fied version of the Linked Version (If you use option 4d0 the InstallationInformation must accompany the Minimal Corresponding Source and Cor-responding Application Code If you use option 4d1 you must provide theInstallation Information in the manner specified by section 6 of the GNUGPL for conveying Corresponding Source)
5 Combined Libraries
You may place library facilities that are a work based on the Library side byside in a single library together with other library facilities that are not Ap-plications and are not covered by this License and convey such a combinedlibrary under terms of your choice if you do both of the following
a) Accompany the combined library with a copy of the same work based onthe Library uncombined with any other library facilities conveyed under theterms of this License b) Give prominent notice with the combined librarythat part of it is a work based on the Library and explaining where to findthe accompanying uncombined form of the same work
6 Revised Versions of the GNU Lesser General Public License
The Free Software Foundation may publish revised andor new versions ofthe GNU Lesser General Public License from time to time Such new versi-ons will be similar in spirit to the present version but may differ in detail toaddress new problems or concerns
Each version is given a distinguishing version number If the Library as youreceived it specifies that a certain numbered version of the GNU Lesser Gene-ral Public License ldquoor any later versionrdquo applies to it you have the option offollowing the terms and conditions either of that published version or of anylater version published by the Free Software Foundation If the Library asyou received it does not specify a version number of the GNU Lesser Gene-ral Public License you may choose any version of the GNU Lesser GeneralPublic License ever published by the Free Software Foundation
If the Library as you received it specifies that a proxy can decide whetherfuture versions of the GNU Lesser General Public License shall apply thatproxyrsquos public statement of acceptance of any version is permanent autho-rization for you to choose that version for the Library
257