3.1) plot(): A Versatile Function
The main function to use for graphs is plot()
. Typing ?plot
leads to a help file for this function that is deceptively brief: you’ll see that the main arguments are x=
and y=
(which must be equal-length vectors), and the Details section hints at how different kinds of objects can be handled. So if x
and y
are both numeric, you get a simple scatter plot. However, it turns out that if x
is a factor, you’ll get a boxplot, or if y
is a factor and x
is continuous, you get a profile plot. If you don’t supply y
, you get the values of x
plotted against their order (assuming x
is numeric, like a time series) – or a bar chart of the frequencies of each value of x
(if x
is a factor).
Let's try these...