lecture_14

lecture_14 - BIOS 735 Statistical Computing Michael Wu...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
BIOS 735: Statistical Computing Michael Wu Lecture 14: Basic R Graphics (Simple Plots) October 11, 2011 Michael Wu (Lecture 14) BIOS 735 October 11, 2011 1 / 14
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Graphics in R R has a lot of capabilities for making pretty pictures – though some claim that MATLAB is even better. High Level graphics functions create a new plot Low Level graphics functions add to existing plots Trellis functions: separate class of functions that create a multi-panel display in a single call Michael Wu (Lecture 14) BIOS 735 October 11, 2011 2 / 14
Background image of page 2
High level functions: As we saw last class, plot is one of the generic functions that are widely applicable: n = 500 case = sample(c(0,1), n, replace = T) age = round(runif(n, 0, 100)) ageGrp = cut(age, seq(0,100, by = 25)) gene1 = rnorm(n) y = 3 * gene1+4 * case+rnorm(n)+.1 * age dat = data.frame(y, gene1,age,case,ageGrp) dat$case.status = factor(case, labels = c("case=0", "case=1") ) plot(gene1); plot(gene1,y); plot(dat) hist(gene1); hist(y) boxplot(y) These are high level functions because they open up new plots/windows. Michael Wu (Lecture 14) BIOS 735 October 11, 2011 3 / 14
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
High level functions: making them prettier hist(y, main = "Histogram of Outcome (y)", xlab = "Outcome (y)", las = 1) main gives the plot a title xlab and ylab gives the x and y axes labels las determines the style of axis labels. Michael Wu (Lecture 14) BIOS 735 October 11, 2011 4 / 14
Background image of page 4
Including Low level functions hist(y, main = "Histogram of Outcome (y)", col = "darkgreen", xlab = "Outcome (y)", las = 1, prob = T) lines(density(y), col = "red", lwd = 5, lty = 2) lines requires an existing plot to be there already (hence low level) Here: I col defines the color (string or number) I lwd gives the line width I lty gives the line type Michael Wu (Lecture 14) BIOS 735 October 11, 2011 5 / 14
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Lattice functions library(lattice)
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 14

lecture_14 - BIOS 735 Statistical Computing Michael Wu...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online