O'Reilly logo

Mastering Scientific Computing with R by Radia M. Johnson, Paul Gerrard

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Visually exploring nonlinear relationships

Let's say that we want to understand the relationship between height, weight, age, and gender. We probably have some preconceived notions about how these variables relate to one another (for example, taller people probably tend to weigh more). Let's perform the following steps:

  1. Firstly, load the data and attach the data frame using the following code:
    body.measures <- read.csv('nhanes_body.txt')
    attach(body.measures)
  2. Now, let's just look at the data visually, as shown in the following diagram, an important first step in most analyses. Let's have a look at the following function:
    plot(age, height, xlab = 'Age', ylab = 'Height', main = 'Height vs Age')

The previous dataset has thousands of data points, so a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required