Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Use geom_bar() without
mapping anything to y
(Figure 3-7):
ggplot(diamonds,aes(x=cut))+geom_bar()# Equivalent to using geom_bar(stat="bin")
The diamonds data set has
53,940 rows, each of which represents information about one
diamond:
diamonds
carat cut color clarity depth table price x y z
1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43
2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31
3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31
...
53939 0.86 Premium H SI2 61.0 58 2757 6.15 6.12 3.74
53940 0.75 Ideal D SI2 62.2 55 2757 5.83 5.87 3.64