Question: Produce an interactive scatterplot of salary on the vertical axis and the years of service on the horizontal axis. Employ radio buttons to color points
A pipe to layer_densities (which youve not yet met) is used to produce kernel density estimates, similar to those appearing in Figure 24-5.
i. Use ggvis to create a static plot of kernel density estimates of salary distributions, split up according to academic rank. To do this, assign the salary variable to x and the rank variable to fill, followed by a pipe to group_by to explicitly instruct grouping by the rank variable. Lastly, piping to layer_densities (just use all default argument values in this instance) will generate the graphic. Your result should resemble the gg4 object from Exercise 24.1.
ii. Just like the width argument to layer_histograms is used to control the appearance of a histogram, the adjust argument in layer_densities is used to control the degree of smoothness of the kernel estimates. Reproduce the rank-specific kernel estimates from the previous plot, but this time, the graphic should be interactiveimplement a slider button with a range of 0.2 to 2 and a label of "Smoothness" to control the smoothing adjustment. At your discretion, either suppress or clarify the axis and legend titles of the result.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
