The Art of R Programming
Figure 12-9: Addition ofd1 12.2.3 Adding a Polygon: The polygon() Function........................ You can usepolygon()to draw a ...
Figure 12-10: Rectangular area strip 12.2.4 Smoothing Points: The lowess() and loess() Functions............... Just plotting a ...
Figure 12-11: Smoothing the exam score relation But you could avoid some work by using thecurve()function, which basi- cally use ...
the same function but with a restrictedxrange. But suppose you wish to dis- play the original plot and the close-up one in the s ...
16 lines(x, y, type = type, ...) 17 else plot(x, y, type = type, ylab = ylab, xlim = xlim, log = lg, ...) 18 return(list(x=x,y=y ...
Figure 12-12: Adding an inset graph 12.3 Saving Graphs to Files...................................................... The R grap ...
The screen is namedX11when R runs on Linux. (It’s namedwindowson Windows systems.) It is device number 2 here. Our PDF file is d ...
12.4 Creating Three-Dimensional Plots............................................. R offers a number of functions to plot data i ...
All the points are connected as a surface (like connecting points by lines in two dimensions). In contrast, withcloud(), the poi ...
...
13 DEBUGGING Programmers often find that they spend more time debugging a program than actually writing it. Good debugging skill ...
Fixing a buggy program is a process of confirming, one by one, that the many things youbelieveto be true about the code actually ...
13.1.4 Antibugging.................................................... You may adopt some “antibugging” strategies as well. Supp ...
So, debugging by insertingprintstatements into your code is slow, cum- bersome, and distracting. If you are serious about progra ...
13.3.2 Using Browser Commands....................................... While you are in the browser, the prompt changes from>to ...
The browser will be invoked only ifsis larger than 1. The following would have the same effect: if (s > 1) browser() Calling ...
13.3.4 Tracking with the trace() Function................................. Thetrace()function is flexible and powerful, though i ...
You can arrange to automatically enter the debugger by writing this code: > options(error=recover) Note, though, that if you ...
n <- length(x) runs <- NULL for (i in 1:(n - k)) { if (all(x[i:i+k-1]==1)) runs <- c(runs, i) } return(runs) } attr(,"s ...
Sincekis 2—that is, we are checking for runs of length 2— theif() statement should be checking the first two elements ofx, which ...
«
11
12
13
14
15
16
17
18
19
20
»
Free download pdf