[R] How to refer a variable in quotes

Jinggaofu Shi js3786 at drexel.edu
Wed Mar 2 23:52:20 CET 2016

Hi, there
I am new to R, here is an urgent question.
I want to save several graphs by a for loop. But I don't know how to refer
the variable in the quotes.
Here is my code.

for (u in 1:9) {pdf("g[u]".pdf")
+ plot(1,1, xlim=range(x), ylim=c(-5,5), type='n', xlab ="Femur length
(mm)", ylab = "Z-Score")
+ mtext("g[u]", side = 4)
+ for (i in z) {
+ lines(x,(log(i)-(m[u]*log(x)+c[u]))/r[u])
+ miny<-(log(i)-(m[u]*log(max(x))+c[u]))/r[u]
+ maxx <- exp((log(i)-c[u]+5*r[u])/m[u]);
+ if (miny > -5) {text(max(x),miny+0.3,i)
+ }else {text(maxx+2, -5+0.3,i)}
+  }
+ dev.off()
+ }

In the second line, I want to refer the variable 'g[n]' to the file name
and fifth line i also want to refer the variable as a note. How should I
do? Thank you very much!

Jinggaofu Shi
4029 Spring Garden Street
Philadelphia, PA 19104
Email: shijinggaofu at gmail.com
Phone: 215-847-9145

	[[alternative HTML version deleted]]

More information about the R-help mailing list