2

Essentials of the R Language

There is an enormous range of things that R can do, and one of the hardest parts of learning R is finding your way around. Likewise, there is no obvious order in which different people will want to learn the different components of the R language. I suggest that you quickly scan down the following bullet points, which represent the order in which I have chosen to present the introductory material, and if you are relatively experienced in statistical computing, you might want to skip directly to the relevant section. I strongly recommend that beginners work thorough the material in the order presented, because successive sections build upon knowledge gained from previous sections. This chapter is divided into the following sections:

  • 2.1 Calculations
  • 2.2 Logical operations
  • 2.3 Sequences
  • 2.4 Testing and coercion
  • 2.5 Missing values and things that are not numbers
  • 2.6 Vectors and subscripts
  • 2.7 Vectorized functions
  • 2.8 Matrices and arrays
  • 2.9 Sampling
  • 2.10 Loops and repeats
  • 2.11 Lists
  • 2.12 Text, character strings and pattern matching
  • 2.13 Dates and times
  • 2.14 Environments
  • 2.15 Writing R functions
  • 2.16 Writing to file from R

Other essential material is elsewhere: beginners will want to master data input (Chapter 3), dataframes (Chapter 4) and graphics (Chapter 5).

2.1 Calculations

The screen prompt > is an invitation to put R to work. The convention in this book is that material that you need to type into the command line after the screen prompt is shown ...

Get The R Book, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.