[R] annotation problems (conditional text())
Johannes Graumann
graumann at caltech.edu
Sat Nov 20 01:21:43 CET 2004
Hello,
I'm trying to annotate my plots nicely and am running into trouble.
This example contains two problems:
a) the 'text()' arguments do not show the conditional behavior I'm
trying to give them. I try to test for the intercept of my regression
and reformat the output accordingly ('+ intercept' in the >= 0 case and
'- sqrt(intercept^2)' in the other case), which doesn't work this way.
b) my pasted substitute commands yield jolted output, which overwrites
itself ...
Can anyone give this newbie a nudge into the right direction?
Thanks, Joh
if(m >= 0){
text(
4,0.19,
cex=0.75,
adj=0,
paste(
substitute(
y == m*x+b,
list(
m=round(m,digits=5),
b=round(b,digits=5)
)
),
"\n",
substitute(
R^2==rsquared,
list(
rsquared=round(summary(fit)$r.squared,digits=3)
)
)
)
);
text(
4,0.19,
cex=0.75,
adj=0,
paste(
substitute(
y == m*x-b,
list(
m=round(m,digits=5),
b=round(sqrt(b^2),digits=5)
)
),
"\n",
substitute(
R^2==rsquared,
list(
rsquared=round(summary(fit)$r.squared,digits=3)
)
)
)
)
}
More information about the R-help
mailing list