[R] 'substitute' question

remko duursma remkoduursma at hotmail.com
Tue Mar 13 14:02:24 CET 2007


# I use this code to label a graph with the R2:

# graph
x <- rnorm(100)
y <- x + rnorm(100)
lm1 <- lm(y~x)
plot(x,y)

# label
R2text <- substitute(paste(R^2," = ",r2),list(r2=r2))
text(1,-3,R2text, col="red")

# i have modified this a bit, so that i have a vector with other labels, 
each of which
# will be labelled on the graph. Example:
texts <- c("And the R2 is", R2text)
x <- c(-2,-2)
y <- c(2,1)
for(i in 1:length(texts))text(x[i],y[i],texts[i],pos=4, col="blue")

# As you can see the label "R2 = 48.7" remains at "paste(R^2, " = ", 48.7)"
# What to do?



Thanks for your help,

Remko



..-~-.-~-.-~-.-~-.-~-.-~-.-~-.-~-.-~-
Remko Duursma
Post-doctoral researcher
Dept. Forest Ecology
University of Helsinki, Finland

_________________________________________________________________
With tax season right around the corner, make sure to follow these few 
simple tips.



More information about the R-help mailing list