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.
library(BrailleR)
library(ggplot2)
library(magrittr)
= diamonds[1:100,] dsmall
= qplot(carat, price, data = diamonds)
g1 # summary(g1)
g1
## 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.
# VI(g1) ### automatic since BrailleR v0.32.0
= qplot(carat, price, data = dsmall, colour = color)
g2 # summary(g2)
g2
## 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 colour is used to show color, with 7 levels:
## D shown as very deep purple colour,
## E shown as vivid purplish blue colour,
## F shown as moderate blue colour,
## G shown as vivid bluish green colour,
## H shown as brilliant green colour,
## I shown as vivid yellow green colour and
## J shown as vivid greenish yellow colour.
## The chart is a set of 100 points.
# g2 %>% VI() ### automatic since BrailleR v0.32.0
= qplot(carat, price, data = dsmall, shape = cut)
g3 # summary(g3)
g3
## 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 shape is used to show cut, with 5 levels:
## Fair shown as solid circle shape,
## Good shown as solid triangle shape,
## Very Good shown as solid square shape,
## Premium shown as plus shape and
## Ideal shown as boxed X shape.
## The chart is a set of 100 points.
#VI(g3) ### automatic since BrailleR v0.32.0
# to get semi-transparent points
= qplot(carat, price, data = diamonds, alpha = I(1/100))
g4 # 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.
## It has alpha set to 0.01.
# VI(g4) ### automatic since BrailleR v0.32.0
# to add a smoother (default is loess for n<1000)
= qplot(carat, price, data = dsmall, geom = c("point", "smooth"))
g5 # 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 'lowess' smoothed curve with 95% confidence intervals.
# VI(g5) ### automatic since BrailleR v0.32.0
#! 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))
# univariate plots
= qplot(carat, data = diamonds, geom = "histogram")
g7a # summary(g7a)
g7a
## `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 with 30 vertical bars.
# VI(g7a) ### automatic since BrailleR v0.32.0
= qplot(carat, data = diamonds, geom = "histogram", binwidth = 1, xlim = c(0,3))
g7b g7b
## 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 with 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.
# VI(g7b) ### automatic since BrailleR v0.32.0
= qplot(carat, data = diamonds, geom = "histogram", binwidth = 0.1, xlim = c(0,3))
g7c g7c
## 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 with 29 vertical bars.
# VI(g7c) ### automatic since BrailleR v0.32.0
= qplot(carat, data = diamonds, geom = "histogram", binwidth = 0.01, xlim = c(0,3))
g7d # 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 with 299 vertical bars.
#VI(g7d) ### automatic since BrailleR v0.32.0
# bar charts for categorical variable
= qplot(color, data = diamonds)
g11a # summary(g11a)
g11a
## 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 with 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.
# VI(g11a) ### automatic since BrailleR v0.32.0
= qplot(color, data = diamonds, geom = "bar")
g11b # summary(g11b)
g11b
## 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 with 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.
# VI(g11b) ### automatic since BrailleR v0.32.0
= qplot(color, data = diamonds, geom = "bar", weight = carat)
g12a # summary(g12a)
g12a
## 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 with 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.
# VI(g12a) ### automatic since BrailleR v0.32.0
= qplot(color, data = diamonds, geom = "bar", weight = carat) + scale_y_continuous("carat")
g12b # 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 with 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.
# VI(g12b) ### automatic since BrailleR v0.32.0
# time series plots
= qplot(date, unemploy / pop, data = economics, geom = "line")
g13a # 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.
# VI(g13a) ### automatic since BrailleR v0.32.0
= qplot(date, uempmed, data = economics, geom = "line")
g13b # summary(g13b)
g13b
## 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.
# VI(g13b) ### automatic since BrailleR v0.32.0
# rescaling of the axes
= qplot(carat, price, data = dsmall, log = "xy")
g16 # summary(g16)
g16
## 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.
#VI(g16) ### automatic since BrailleR v0.32.0