Base Graphics

Author
Affiliation

Beau B. Bruce, MD, PhD

Emory University

Evaluation

The goal of this assignment is to recreate the following plot exactly (e.g., pay particular attention to the type and color of points and lines and the axis labels, etc.) using the provided data described below.

The figure of the caption of the figure should also help you recreate it.

``Figure. Mean optic nerve size vs. age in patients with optic nerve hypoplasia (ONH) and controls. Linear regression of the mean optic nerve size of controls (black points: individual control optic nerve measurements, black line: mean optic nerve size of controls, dashed black lines: 95% prediction intervals of mean optic nerve size of controls). Red points are measurements of optic nerves with clinical ONH. Blue points represent the clinically unaffected eye of patients with clinically unilateral ONH. The contralateral optic nerve of ONH patients was generally smaller than control optic nerves.’’

There are two datasets. Dataset onhlong contains the individual measurements on each row. case tells us whether the patient was a case or not (factor: 1 vs. 0), clinhypo if the nerve was clinically hypoplastic (factor: Yes vs. No), age of the subject, and mean the mean optic nerve measurement.

Take a look at the first few rows of onhlong below.

Dataset onhfit contains predicted values for the regression line mean and the upper (upr95) and lower (lwr95). Each would be plotted by onhfit’s age variable to create the lines.

Take a look at all of onhfit below.

Here are some hints to get you started (replace the ...’s with your code):

Finally, if you are struggling with the plot window x and y limits, remember that they can be set automatically by R based on the data you provide if you remember to set type = "n" in the right place (see the notes we went over in class).

Note

I’m not going to provide the full solution here. But hopefuly the hints above, the feedback from the autograder, and the class resources will help you get there!

Submit Your Assignment