Session Ready
Exercise

Exploring a Distribution with rxHistogram()

We can plot a histogram of a variable with rxHistogram()

Instructions
100 XP

Use rxHistogram() to create a histogram for the Close variable.

The syntax is: Function(formula, data, …)

  • formula - A formula that contains the variable which you want to visualize. The simple case is a formula with only a single variable to the right side of the ~.
  • data - The dataset in which you want to search for the variable(s) used in formula.
  • … - Additional arguments.

Go ahead and use rxHistogram() to construct a default histogram of the variable reflecting closing price.

Next, go ahead and use rxHistogram() to construct a default histogram of the categorical variable reflecting day of the week.

We can also use more complex formula arguments in rsHistogram() to construct histograms for distinct subsets of data. In these more complex formulae, we specify the variables we want to have unique panels for on the right side of a | symbol. This functionality parallels the formalism of the histogram() function available in the lattice package.

Now, go ahead and use rxHistogram() to contruct a multi-panel histogram of closing price, with one panel for each day of the week.

Finally, we can use additional arguments to do frequency or probability weighting (fweights and pweights respectively).

Go ahead and create a historgram of closing value, but this time, use the volume traded as a frequency weight.