This vignette contained many more plots in its initial development. The set has been cut back considerably to offer meaningful testing only, and because much of the material was moved over to a book called BrailleR in Action. Doing so also had an advantage of speeding up the package creation, testing, and installation. N.B. the commands here are either exact copies of the commands presented in Wickham (2009) or some minor alterations to them. Notably, some code given in the book no longer works. This is given a #!
The ggplot2
package has a summary
method that often but not always offers something to show that things have changed from one plot to another. Summary commands are included below but commented out.
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:BrailleR':
##
## xlab, ylab
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'carat' with labels 0, 1, 2, 3, 4 and 5.
## It has y-axis 'price' with labels 0, 5000, 10000 and 15000.
## The chart is a set of 53940 points.
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'carat' with labels 0.2, 0.4, 0.6 and 0.8.
## It has y-axis 'price' with labels 1000 and 2000.
## There is a legend indicating that colour is used to represent color, with 7 levels:
## D represented by colour very deep purple,
## E represented by colour vivid purplish blue,
## F represented by colour moderate blue,
## G represented by colour vivid bluish green,
## H represented by colour brilliant green,
## I represented by colour vivid yellow green and
## J represented by colour vivid greenish yellow.
## The chart is a set of 100 points.
## Warning: Using shapes for an ordinal variable is not advised
## Warning: Using shapes for an ordinal variable is not advised
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'carat' with labels 0.2, 0.4, 0.6 and 0.8.
## It has y-axis 'price' with labels 1000 and 2000.
## There is a legend indicating that shape is used to represent cut, with 5 levels:
## Fair represented by shape solid circle,
## Good represented by shape solid triangle,
## Very Good represented by shape solid square,
## Premium represented by shape plus and
## Ideal represented by shape boxed X.
## The chart is a set of 100 points.
# to get semi-transparent points
g4 = qplot(carat, price, data = diamonds, alpha = I(1/100))
# summary(g4)
g4
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'carat' with labels 0, 1, 2, 3, 4 and 5.
## It has y-axis 'price' with labels 0, 5000, 10000 and 15000.
## The chart is a set of 53940 points.
## The chart has alpha set to 0.01.
# to add a smoother (default is loess for n<1000)
g5 = qplot(carat, price, data = dsmall, geom = c("point", "smooth"))
# summary(g5)
g5
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'carat' with labels 0.2, 0.4, 0.6 and 0.8.
## It has y-axis 'price' with labels 0, 1000, 2000 and 3000.
## It has 2 layers.
## Layer 1 is a set of 100 points.
## Layer 2 is a smoothed curve using method 'auto' with confidence intervals.
#! g5a = qplot(carat, price, data = dsmall, geom = c("point", "smooth"), span = 1)
library(splines)
#! g5b = qplot(carat, price, data = dsmall, geom = c("point", "smooth"), method = "lm")
#! g5c = qplot(carat, price, data = dsmall, geom = c("point", "smooth"), method = "lm", formula = y ~ ns(x,5))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'carat' with labels 0, 1, 2, 3, 4 and 5.
## It has y-axis '' with labels 0, 5000, 10000 and 15000.
## The chart is a bar chart containing 30 vertical bars.
## Warning: Removed 32 rows containing non-finite values (stat_bin).
## Warning: Removed 2 rows containing missing values (geom_bar).
## Warning: Removed 32 rows containing non-finite values (stat_bin).
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'carat' with labels 0, 1, 2 and 3.
## It has y-axis '' with labels 0, 10000, 20000 and 30000.
## The chart is a bar chart containing 2 vertical bars.
## Bar 1 is centered horizontally at 1, and spans vertically from 0 to 29566.
## Bar 2 is centered horizontally at 2, and spans vertically from 0 to 5316.
## Warning: Removed 32 rows containing non-finite values (stat_bin).
## Warning: Removed 2 rows containing missing values (geom_bar).
## Warning: Removed 32 rows containing non-finite values (stat_bin).
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'carat' with labels 0, 1, 2 and 3.
## It has y-axis '' with labels 0, 2500, 5000, 7500 and 10000.
## The chart is a bar chart containing 29 vertical bars.
g7d = qplot(carat, data = diamonds, geom = "histogram", binwidth = 0.01, xlim = c(0,3))
# summary(g7d)
g7d
## Warning: Removed 32 rows containing non-finite values (stat_bin).
## Warning: Removed 2 rows containing missing values (geom_bar).
## Warning: Removed 32 rows containing non-finite values (stat_bin).
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'carat' with labels 0, 1, 2 and 3.
## It has y-axis '' with labels 0, 1000 and 2000.
## The chart is a bar chart containing 299 vertical bars.
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'color' with labels D, E, F, G, H, I and J.
## It has y-axis '' with labels 0, 3000, 6000 and 9000.
## The chart is a bar chart containing 7 vertical bars.
## Bar 1 is centered horizontally at D, and spans vertically from 0 to 6775.
## Bar 2 is centered horizontally at E, and spans vertically from 0 to 9797.
## Bar 3 is centered horizontally at F, and spans vertically from 0 to 9542.
## Bar 4 is centered horizontally at G, and spans vertically from 0 to 11292.
## Bar 5 is centered horizontally at H, and spans vertically from 0 to 8304.
## Bar 6 is centered horizontally at I, and spans vertically from 0 to 5422.
## Bar 7 is centered horizontally at J, and spans vertically from 0 to 2808.
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'color' with labels D, E, F, G, H, I and J.
## It has y-axis '' with labels 0, 3000, 6000 and 9000.
## The chart is a bar chart containing 7 vertical bars.
## Bar 1 is centered horizontally at D, and spans vertically from 0 to 6775.
## Bar 2 is centered horizontally at E, and spans vertically from 0 to 9797.
## Bar 3 is centered horizontally at F, and spans vertically from 0 to 9542.
## Bar 4 is centered horizontally at G, and spans vertically from 0 to 11292.
## Bar 5 is centered horizontally at H, and spans vertically from 0 to 8304.
## Bar 6 is centered horizontally at I, and spans vertically from 0 to 5422.
## Bar 7 is centered horizontally at J, and spans vertically from 0 to 2808.
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'color' with labels D, E, F, G, H, I and J.
## It has y-axis '' with labels 0, 2500, 5000 and 7500.
## The chart is a bar chart containing 7 vertical bars.
## Bar 1 is centered horizontally at D, and spans vertically from 0 to 4456.56.
## Bar 2 is centered horizontally at E, and spans vertically from 0 to 6445.12.
## Bar 3 is centered horizontally at F, and spans vertically from 0 to 7028.05.
## Bar 4 is centered horizontally at G, and spans vertically from 0 to 8708.28.
## Bar 5 is centered horizontally at H, and spans vertically from 0 to 7571.58.
## Bar 6 is centered horizontally at I, and spans vertically from 0 to 5568.
## Bar 7 is centered horizontally at J, and spans vertically from 0 to 3263.28.
g12b = qplot(color, data = diamonds, geom = "bar", weight = carat) + scale_y_continuous("carat")
# summary(g12b)
g12b
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'color' with labels D, E, F, G, H, I and J.
## It has y-axis '' with labels 0, 2500, 5000 and 7500.
## The chart is a bar chart containing 7 vertical bars.
## Bar 1 is centered horizontally at D, and spans vertically from 0 to 4456.56.
## Bar 2 is centered horizontally at E, and spans vertically from 0 to 6445.12.
## Bar 3 is centered horizontally at F, and spans vertically from 0 to 7028.05.
## Bar 4 is centered horizontally at G, and spans vertically from 0 to 8708.28.
## Bar 5 is centered horizontally at H, and spans vertically from 0 to 7571.58.
## Bar 6 is centered horizontally at I, and spans vertically from 0 to 5568.
## Bar 7 is centered horizontally at J, and spans vertically from 0 to 3263.28.
# time series plots
g13a = qplot(date, unemploy / pop, data = economics, geom = "line")
# summary(g13a)
g13a
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'date' with labels 1970, 1980, 1990, 2000 and 2010.
## It has y-axis 'unemploy/pop' with labels 0.02, 0.03, 0.04 and 0.05.
## The chart is a set of 1 line.
## Line 1 connects 574 points.
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'date' with labels 1970, 1980, 1990, 2000 and 2010.
## It has y-axis 'uempmed' with labels 5, 10, 15, 20 and 25.
## The chart is a set of 1 line.
## Line 1 connects 574 points.
## This is an untitled chart with no subtitle or caption.
## It has x-axis 'carat' with labels 0.3, 0.5 and 1.0.
## It has y-axis 'price' with labels 300, 1000 and 3000.
## The chart is a set of 100 points.