Graphics Reference
In-Depth Information
Figure 4-1. Basic line graph
Discussion
In this sample data set, the xvariable, Time , is in one column and the yvariable, demand , is in
another:
BOD
Time demand
1
8.3
2
10.3
3
19.0
4
16.0
5
15.6
7
19.8
Line graphs can be made with discrete (categorical) or continuous (numeric) variables on the x-
axis. In the example here, the variable demand is numeric, but it could be treated as a categorical
variable by converting it to a factor with factor() ( Figure 4-2 ). When the xvariable is a factor,
you must also use aes(group=1) to ensure that ggplot() knows that the data points belong
Search WWH ::




Custom Search