The user can choose either to plot the next sequential degree or select a
different one. The query, both user prompt and reading of the user’s reply,
is done in this line:
rl <- readline(prompt)
We use the R string functionpaste()to assemble a prompt, offering the
user a choice of plotting the next fitted polynomial, plotting one of a differ-
ent degree, or quitting. The prompt appears in the interactive R window in
which we issued theplot()call. For instance, after taking the default choice
twice, the command window looks like this:
plot(lmo)
RETURN for XV fit for degree 1 or type degree or q for quit
RETURN for XV fit for degree 2 or type degree or q for quit
RETURN for XV fit for degree 3 or type degree or q for quit
The plot window looks like Figure 12-5.
Figure 12-5: Plotting a polynomial fit
12.1.6 Adding Points: The points() Function..............................
Thepoints()function adds a set of (x,y) points, with labels for each, to the
currently displayed graph. For instance, in our first example, suppose we
entered this command:
points(testscores$Exam1,testscores$Exam3,pch="+")
Graphics 269