Chapter 11. Data Visualization Using Lattice

In this chapter, we will cover the following recipes:

  • Creating bar charts
  • Creating stacked bar charts
  • Creating bar charts to visualize cross-tabulation
  • Creating a conditional histogram
  • Visualizing distributions through a kernel-density plot
  • Creating a normal Q-Q plot
  • Visualizing an empirical Cumulative Distribution Function
  • Creating a boxplot
  • Creating a conditional scatter plot

Introduction

In this chapter, we intend to show you data visualization using the lattice package where producing conditional plots is much easier than the basic graphs. The focal point of the chapter will be basic graphs that are most commonly used during data visualization. Starting from a single variable bar chart, we will continue to conditional scatter plots. We will primarily use the lattice package to produce the graphs, but we will use other packages when required. If we use any other package, then we will mention the reason for that in the respective sections.

We will supply the dataset for this chapter or generate datasets through very simple random number generation functions in R. For example, runif() is used to generate a random number from a uniform distribution, rnorm() is used to generate a random variable from a normal distribution, and rbinom() is used to generate a binomial random variable. During the data generation process, we will use the code in such a way that all the examples can be reproduced at any time.

We might not use all the arguments of the functions used for each recipe, so it would be good to have a look at the possible arguments on the help documentation page. Before starting the actual recipe, let's set the following:

  • The working directory to a convenient location
  • Load the lattice library to your current working session

Now, let's start the actual recipe!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.214.202