How it works...

Figure 2.6 (section How to do it...) represents the output given by running the code from step 1. It starts with set.seeds() to make sure that both you and me achieve the very same result; function sets the seed number used for pseudo random generation processes. Call this function whenever you want to turn a "random" process reproducible.

Then, after drawing the regular ggplot2 scatter, the only thing needed to add jitter to the points was to operate position = 'jitter' inside the geom_point() layer. Another way to go is to replace geom_point() with geom_jitter(), and skip the position argument. For some occasions, that would be a better way, as it enables a great deal of arguments resulting in more control over the jittering process.

Step 2 uses the function rnorm() to create the objects jx (jitter x) and jy (jitter y). Both are designed to work as little noises. Function rnorm() is creating a vector of numbers "randomly" (pseudo-randomly) sorted from a normal distribution with given mean and standard deviation (sd).

Normal distributions are not the only ones that can be generated. Functions rt(), rpois() and rbinom() respectively generates student, poisson and binomial distributions. There are more options available. 

Steps 3 and 4 are analogous to each other. While step 3 is adding the noises (jx and jy) to variables inputted as x and y using plotly, step 4 does about the same but using ggvis instead. By doing this jitter technique was applied using both plotly and ggvis. Noises were stored in separated vectors and the data frame remais unchanged.