1. Please spend some time with an R tutorial or two to become familiar with R basics.
2. Please do not post in HTML. This is a plain text email list. 3. See e.g. ?sprintf or ?paste for your problem. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, Mar 2, 2016 at 2:52 PM, Jinggaofu Shi <js3...@drexel.edu> wrote: > 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. > > g<-c("g1","g2","g3","g4","g5","g6","g7","g8","g9") > 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! > > -- > Sincerely, > Jinggaofu Shi > 4029 Spring Garden Street > Philadelphia, PA 19104 > Email: shijingga...@gmail.com > Phone: 215-847-9145 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.