lecture_14

# lecture_14 - BIOS 735: Statistical Computing Michael Wu...

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

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

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

View Full Document
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
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

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

View Full Document
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
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 deﬁnes 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

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

View Full Document
Lattice functions library(lattice)
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/18/2011 for the course BIOS 735 taught by Professor Staff during the Spring '10 term at UNC.

### 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
Ask a homework question - tutors are online