Unformatted text preview:

ggplot2 pima data Univariate Bivariate Regression lines Stat 849 ggplot2 graphics Douglas Bates University of Wisconsin Madison and R Development Core Team Douglas Bates R project org Sept 08 2010 Ancova ggplot2 pima data Univariate Bivariate Outline ggplot2 The pima data set from the faraway package Univariate summary plots Bivariate plots Simple regression or ancova lines Ancova Regression lines Ancova ggplot2 pima data Univariate Bivariate Outline ggplot2 The pima data set from the faraway package Univariate summary plots Bivariate plots Simple regression or ancova lines Ancova Regression lines Ancova ggplot2 pima data Univariate Bivariate Outline ggplot2 The pima data set from the faraway package Univariate summary plots Bivariate plots Simple regression or ancova lines Ancova Regression lines Ancova ggplot2 pima data Univariate Bivariate Outline ggplot2 The pima data set from the faraway package Univariate summary plots Bivariate plots Simple regression or ancova lines Ancova Regression lines Ancova ggplot2 pima data Univariate Bivariate Outline ggplot2 The pima data set from the faraway package Univariate summary plots Bivariate plots Simple regression or ancova lines Ancova Regression lines Ancova ggplot2 pima data Univariate Bivariate Outline ggplot2 The pima data set from the faraway package Univariate summary plots Bivariate plots Simple regression or ancova lines Ancova Regression lines Ancova ggplot2 pima data Univariate Bivariate Outline ggplot2 The pima data set from the faraway package Univariate summary plots Bivariate plots Simple regression or ancova lines Ancova Regression lines Ancova ggplot2 pima data Univariate Bivariate Regression lines The ggplot2 graphics package Another advanced graphics package for R is ggplot2 by Hadley Wickham a recent Iowa State Stats Ph D now at Rice His book is listed as one of the references on the course web site The core chapter introducing the basic function called qplot can be obtained from the URL in the links section on the course web site I will use data from the faraway package to accompany Julian Faraway s freely available book Practical Regression and Anova using R to illustrate the use of qplot Ancova ggplot2 pima data Univariate Bivariate Outline ggplot2 The pima data set from the faraway package Univariate summary plots Bivariate plots Simple regression or ancova lines Ancova Regression lines Ancova ggplot2 pima data Univariate Bivariate Regression lines Ancova Examining the pima data library faraway str pima data frame pregnant glucose diastolic triceps insulin bmi diabetes age test 768 obs of 9 variables int 6 1 8 1 0 5 3 10 2 8 int 148 85 183 89 137 116 78 115 197 125 int 72 66 64 66 40 74 50 0 70 96 int 35 29 0 23 35 0 32 0 45 0 int 0 0 0 94 168 0 88 0 543 0 num 33 6 26 6 23 3 28 1 43 1 25 6 31 35 3 30 5 0 num 0 627 0 351 0 672 0 167 2 288 int 50 31 32 21 33 30 26 29 53 54 int 1 0 1 0 1 0 1 0 1 1 head pima 1 2 3 4 5 6 pregnant glucose diastolic triceps insulin bmi diabetes age test 6 148 72 35 0 33 6 0 627 50 1 1 85 66 29 0 26 6 0 351 31 0 8 183 64 0 0 23 3 0 672 32 1 1 89 66 23 94 28 1 0 167 21 0 0 137 40 35 168 43 1 2 288 33 1 5 116 74 0 0 25 6 0 201 30 0 ggplot2 pima data Univariate Bivariate Regression lines Ancova Recoding the missing data As Faraway indicates several of the values of variables that cannot reasonably be zero are recorded as zero A bit of research shows that these are missing data values Also the test variable is a factor not numeric pima within pima diastolic diastolic 0 glucose glucose 0 triceps triceps 0 insulin insulin 0 bmi bmi 0 NA test factor test labels c negative positive head pima 3 pregnant glucose diastolic triceps insulin bmi diabetes age 6 148 72 35 NA 33 6 0 627 50 1 85 66 29 NA 26 6 0 351 31 8 183 64 NA NA 23 3 0 672 32 test 1 positive 2 negative 3 positive 1 2 3 ggplot2 pima data Univariate Bivariate Outline ggplot2 The pima data set from the faraway package Univariate summary plots Bivariate plots Simple regression or ancova lines Ancova Regression lines Ancova ggplot2 pima data Univariate Bivariate Regression lines Histogram of diastolic blood pressure qplot diastolic data pima geom histogram 100 80 count 60 40 20 0 20 40 60 80 diastolic 100 120 Ancova ggplot2 pima data Univariate Bivariate Regression lines Ancova Histogram of diastolic bp by test qplot diastolic data pima geom histogram fill test 100 80 60 count test negative positive 40 20 0 20 40 60 80 Diastolic blood pressure mg Hg 100 120 ggplot2 pima data Univariate Bivariate Regression lines Ancova Empirical density plot qplot diastolic data pima geom density 0 030 0 025 density 0 020 0 015 0 010 0 005 0 000 40 60 80 Diastolic blood pressure mg Hg 100 120 ggplot2 pima data Univariate Bivariate Regression lines Ancova Empirical density of diastolic by test qplot diastolic data pima geom density color test 0 030 0 025 density 0 020 test negative positive 0 015 0 010 0 005 0 000 40 60 80 Diastolic blood pressure mg Hg 100 120 ggplot2 pima data Univariate Bivariate Outline ggplot2 The pima data set from the faraway package Univariate summary plots Bivariate plots Simple regression or ancova lines Ancova Regression lines Ancova ggplot2 pima data Univariate Bivariate Regression lines Ancova Simple scatterplot c f Fig 1 2a p 13 qplot diastolic diabetes data pima xlab 2 0 Diabetes pedigree function 1 5 40 60 1 0 0 5 80 Diastolic blood pressure mg Hg 100 120 ggplot2 pima data Univariate Bivariate Regression lines Ancova Adding a scatterplot smoother qplot diastolic diabetes data pima geom c point smooth 2 0 Diabetes pedigree function 1 5 40 60 1 0 0 5 80 Diastolic blood pressure mg Hg 100 120 ggplot2 pima data Univariate Bivariate Regression lines Ancova Multiple smoothers by group qplot diastolic diabetes data pima geom c point smooth color test 2 0 Diabetes pedigree function 1 5 40 60 1 0 0 5 80 Diastolic blood pressure mg Hg test 100 120 negative positive ggplot2 pima data Univariate Bivariate Regression lines Comparative boxplots apparently only vertical qplot test diabetes data pima geom c boxplot 2 0 Diabetes pedigree function 1 5 1 0 0 5 negative positive Diabetes test result Ancova ggplot2 pima data Univariate Bivariate Outline ggplot2 The pima data set from the faraway package Univariate summary plots Bivariate plots Simple regression or ancova lines Ancova Regression lines Ancova ggplot2 pima data Univariate Bivariate Regression lines Ancova Adding a simple linear regression line c f Fig 1 3 p 14 p qplot midterm


View Full Document

UW-Madison STAT 849 - ggplot2 graphics

Download ggplot2 graphics
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view ggplot2 graphics and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view ggplot2 graphics 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?