[R] greek in main title
Oldradio69@aol.com
Oldradio69 at aol.com
Tue Jul 22 17:11:17 CEST 2003
Hello,
I have written a function that demonstrates the CLT by
generating samples following the exponential distribution,
calculating the means, plotting the histogram, and drawing
the limiting normal curve as an overlay. I have the title
of each histogram state the sample size and rate (1/theta)
for the exponential (the output is actually 4 histograms),
but I can't get the greek letter theta to appear in the
heading. Is this possible? I can get nontext for the xlab
and ylab pretty easily.
Thanks, Jason
Below is my code. Currently it just writes out "theta."
function (theta)
{
layout(matrix(c(1:4),2,2,byrow=TRUE))
par(bg = "cornsilk")
n <- c(1,10,25,50)
for(i in 1:4) {
xbar <- rep(0, 1000)
for (j in 1:1000)
xbar[j] <- mean(rexp(n[i], rate = 1/theta))
heading <- paste("Exp w/ theta =", theta, ", n = ", n[i])
hist(xbar, prob = TRUE, breaks = "FD", main = title(heading, font.main = 6),
col = "lightgray", xlab = expression(bar(x)))
xbar <- sort(xbar)
points(xbar, dnorm(xbar, mean = theta, sd = theta/sqrt(n[i])),
type = "l", col = 2)
}
}
More information about the R-help
mailing list