An Introduction to RRough Draft∗The Berkeley R ProjectUC Berkeley, Department of StatisticsVIGREJohn Jimenez†The Berkeley R [email protected] Shurick‡The Berkeley R [email protected] 8, 2008∗Though incomplete at this stage, the tutorial should get the beginner quite far.†Sections 1.2 (examples from prof. Rice), 1.3, 2.2 (ending “—>” section), 2.3 (strsplit section), 2.6 (from accessing(i,j) elements on), 2.7, 2.8, 2.10.1, 3, 4, 5, 6, 8, and 9.‡Sections 1.1, 2.1 - 2.3, 2.4 - 2.11, and 71Contents1 Introduction 61.1 What is R? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.2 What can I do with R? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.3 How Can I Get a Copy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.4 The Focus of this Tutorial, and other References . . . . . . . . . . . . . . . . . . . . 82 Objects 82.1 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.2 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.2.1 Creating Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.2.2 Indexing Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.2.3 Vector Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.3 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.4 Factors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.5 List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.6 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.7 Data-Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182.8 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.9 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.10 Other Things You Must Know About R . . . . . . . . . . . . . . . . . . . . . . . . . 222.10.1 Logical and Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . 232.11 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 Plotting 253.1 Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.1.1 colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.2 Box-Plots : . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.3 Scatter-Plots : . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273.4 Putting Multiple Graphs in One Figure . . . . . . . . . . . . . . . . . . . . . . . . . 293.4.1 par . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293.4.2 split.screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303.4.3 Replacing a Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303.4.4 Split Screens within Split Screens . . . . . . . . . . . . . . . . . …
View Full Document