Lecture 3.2 Lyx-Math Notation and Functions

Plotmath plotting functions that take arguments for

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: h Plotting functions that take arguments for text generally allow expressions for math symbols Lecture 3.2 Writing Your Own Functions in R Introduction to Lyx Mathematical Notation in R Writing Functions in R Using function expression() 1 Some examples. plot(0, 0, main = expression(theta == 0), ylab = expression(hat(gamma) == 0), xlab = expression(sum(x[i] * y[i], i==1, n))) 2 Pasting strings together. x = rnorm(100) hist(x, xlab=expression("The mean (" * bar(x) * ") is " * sum(x[i]/n,i==1,n))) Lecture 3.2 Writing Your Own Functions in R Introduction to Lyx Mathematical Notation in R Writing Functions in R Using function substitue() What if you want to use a computed value in the annotation? x <- rnorm(100) y <- x + rnorm(100, sd = 0.5) plot(x, y, xlab=substitute(bar(x) == k, list(k=mean(x))), ylab=substitute(bar(y) == k, list(k=mean(y))) ) Or in a loop of plots par(mfrow = c(2, 2)) for(i in 1:4) { x = rnorm(100) hist(x, main=substitute(theta==num,list(num=i))) } Lecture 3.2 Writing Your Own Functions in R Introduction to Lyx Mathematical Notation in R Writing Functions in R More on math notation See plotmath in R ?plotmath Lecture 3.2 Writing Your Own Functions in R Introduction to Lyx Mathematical Notation in R Writing Functions in R Lecture 3.2 Writing Your Own Functions in R...
View Full Document

This document was uploaded on 12/05/2013.

Ask a homework question - tutors are online