June 2007
Beginner to intermediate
950 pages
27h 8m
English
The default xlab and ylab do not allow subscripts like r2 or superscripts or xi. For these you need to master the expression function. In R, the operator for superscripts is ‘hat’ (or, more correctly, ‘caret’) so ‘r squared’ is written r^2. Likewise subscripts in R involve square brackets [] so xi is written x[i]. Suppose that we want r2 to be the label on the y axis and xi to be the label on the x axis. The expression function turns R code into text like this:
plot(1:10,1:10, ylab=expression(r^2), xlab=expression(x[i]),type="n")
Read now
Unlock full access