The Art of R Programming
But what if you want to search for a period usinggrep()? Here’s the naive approach: > grep(".",c("abc","de","f.g")) [1]123 Th ...
A key aspect is the argumentfixed=TRUE. Without it, the splitting argu- ment.(calledsplitin the list ofstrsplit()’s formal argum ...
The main point in this example is the string manipulation we use to cre- ate the filenamefname. For more details about the graph ...
What is going on here? The main point is thatedtdbgsends remote com- mands to the Vim text editor. For instance, if you are runn ...
To get the buffer name, using the preceding example as a guide, we see that the name comes afterdebug atand ends just before the ...
...
12 GRAPHICS R has a very rich set of graphics facilities. The R home page (http://www.r-project .org/) has a few colorful exampl ...
12.1.1 The Workhorse of R Base Graphics: The plot() Function............. Theplot()function forms the foundation for much of R’s ...
12.1.2 Adding Lines: The abline() Function............................... We now have an empty graph, ready for the next stage, ...
You can add more lines using thelines()function. Though there are many options, the two basic arguments tolines()are a vector of ...
plot(d1,main="",xlab="") lines(d2) First, we compute nonparametric density estimates from the two vari- ables, saving them in ...
Note that we asked R to use blank labels for the figure as a whole and for thex-axis. Otherwise, R would have gotten such labels ...
24 n <- length(fits$y) 25 tbl <- matrix(nrow=maxdeg,ncol=1) 26 cat("mean squared prediction errors, by degree\n") 27 colna ...
71 # regress, leaving out ith observation 72 lmo <- lm(y[-i] ~ xmat[-i,]) 73 betahat <- as.vector(lmo$coef) 74 # the 1 acc ...
The user can choose either to plot the next sequential degree or select a different one. The query, both user prompt and reading ...
The result would be to superimpose onto the current graph the points of the exam scores from that example, using plus signs (+) ...
Figure 12-6: Placing text 12.1.9 Pinpointing Locations: The locator() Function....................... Placing text exactly where ...
This has R draw a histogram and then callslocator()with the argu- ment 1 , indicating we will click the mouse once. After the cl ...
parameter in various graphing functions. For instance, you may wish to draw the text “abc” at some point, say (2.5,4), in your g ...
First we drew the bare-bones plot—just axes without innards, as shown in Figure 12-7. The first two arguments toplot()givexliman ...
«
10
11
12
13
14
15
16
17
18
19
»
Free download pdf