♣9♣Visualisation Methods
This section demonstrates – in no particular order – some of the most useful plotting facilities in R.1
The most important function to plot anything is
plot(). The OO implementation of R is function centric and the plot-function will recognize what object is fed to it and then dispatch to the relevant function. The effect is that you can provide a wide variety of objects to the function
plot() and that R will “magically” present something that makes sense for that particular object.
We illustrate this with the two very basic and simple objects, a vector and a data frame (the plots appear respectively in Figure 9.1 on page 160 and Figure 9.2 on page 160):
If the standard plot for your object is not what you need, you can choose one of the many specific plots that we illustrate in the remainder of this chapter.
Figure 9.1: The plot-function will generate a scatter-plot for a vector. Note also that the legend is automatically adapted. The xis is the index of the number in the vector and the y-axis is the value of the corresponding number in the vector.
Figure 9.2: The plot-function will generate a scatter-plot of each column in function ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access