High-Level Lattice Plotting Functions

This section describes high-level lattice functions. (We’ll cover panel functions in the next section.) We’ll start with functions for plotting a single vector of values, then functions for plotting two variables, then functions for plotting three variables, and some other functions that build on these functions.

Univariate Trellis Plots

In this section, I’m going to use the same data set for most of the examples: births in the United States during 2006.[43] The original data file contains a record for every birth in the United States during 2006, but the version that is included in the nutshell package only contains a 10% sample. Each record includes the following variables:

DOB_MM

Month of birth

DOB_WK

Day of week of birth

MAGER

Mother’s age

TBO_REC

Total birth order

WTGAIN

Weight gain (by mother)

SEX

Sex of the child (M or F)

APGAR5

Apgar score

DMEDUC

Mother’s education

UPREVIS

Number of prenatal visits

ESTGEST

Estimated weeks of gestation

DMETH_REC

Delivery method

DPLURAL

“Plural” births (i.e., single, twins, triplets, etc.)

DBWT

Birth weight (in grams)

It takes a little while to process the raw data, so I’ve included a 10% sample of this data set within the nutshell package as births2006.smpl.

Get R in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.