The Art of R Programming
INTRODUCTION R is a scripting language for statistical data manipulation and analysis. It was inspired by, and is mostly compati ...
R has a number of virtues: It is a public-domain implementation of the widely regarded S statistical language, and the R/S plat ...
shell commands using pipes.) The ability to combine R functions gives tre- mendous flexibility and, if used properly, is quite p ...
As you will see, the functional programming nature of the R language offers many advantages: Clearer, more compact code Potenti ...
included a discussion of design alternatives, answering the question “Why did we do it this way?” The material is approached wi ...
...
1 GETTING STARTED As detailed in the introduction, R is an ex- tremely versatile open source programming language for statistics ...
not require interaction with the user. It’s useful for production jobs, such as when a program must be run periodically, say onc ...
Here, there are 10 values in the output, and the label[7]in the sec- ond row lets you quickly see that 0.6877001, for instance, ...
1.2 A First R Session............................................................ Let’s make a simple data set (in R parlance, a ...
The expressionx[2:3]refers to the subvector ofxconsisting of elements 2 through 3, which are 2 and 4 here. We can easily find th ...
We can also plot a histogram of the data: > hist(Nile) A window pops up with the histogram in it, as shown in Figure 1-1. Thi ...
That last prompt asks whether you want to save your variables so that you can resume work later. If you answery, then all those ...
Notice that the modulo operator for remainder arithmetic is%%in R, as indicated by the comment. For example, 38 divided by 7 lea ...
In programming language terminology,xis theformal argument(or formal parameter) of the functionoddcount(). In the first function ...
Hereywill be initialized to 2 if the programmer does not specifyyin the call. Similarly,zwill have the default valueTRUE. Now co ...
1.4.2 Character Strings............................................... Character strings are actually single-element vectors of ...
additional attributes: the number of rows and the number of columns. Here is some sample matrix code: > m <- rbind(c(1,4), ...
$u [1] 2 $v [1] "abc" x$u [1] 2 The expressionx$urefers to theucomponent in the listx. The latter con- tains one other compone ...
attr(,"class") [1] "histogram" Don’t try to understand all of that right away. For now, the point is that, besides making a grap ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf