Hello, I was wondering if someone could tell me how I can make text dependent on a variable in a R function I have created. The function will create plots, thus I would like each plot to have a unique title based on the inputted variable as well as a unique file name when saved using the savePlot function. Thanks! Rachel _________________________________________________________________ The New Busy is not the old busy. Search, chat and e-mail from your inbox. N:WL:en-US:WM_HMP:042010_3 [[alternative HTML version deleted]]
On Sun, 2 May 2010, R K wrote:> > Hello, > > I was wondering if someone could tell me how I can make text dependent > on a variable in a R function I have created.example( deparse ) HTH, Chuck> > The function will create plots, thus I would like each plot to have a unique title based on the inputted variable as well as a unique file name when saved using the savePlot function. > > Thanks! > Rachel > > _________________________________________________________________ > The New Busy is not the old busy. Search, chat and e-mail from your inbox. > > N:WL:en-US:WM_HMP:042010_3 > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > 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. >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
On 05/02/2010 11:56 AM, R K wrote:> > Hello, > > I was wondering if someone could tell me how I can make text dependent on a variable in a R function I have created. > > The function will create plots, thus I would like each plot to have a unique title based on the inputted variable as well as a unique file name when saved using the savePlot function. >Hi Rachel, I think what you are looking for is the somewhat obscure: deparse(substitute(x)) that returns the name of a variable as a character string. Jim
say x is the variable. plot(..., title=paste(x, "whatever else"), ...) should work as well. same should work with file names as well. Nikhil On May 1, 2010, at 9:56 PM, R K wrote:> > Hello, > > I was wondering if someone could tell me how I can make text > dependent on a variable in a R function I have created. > > The function will create plots, thus I would like each plot to have > a unique title based on the inputted variable as well as a unique > file name when saved using the savePlot function. > > Thanks! > Rachel > > _________________________________________________________________ > The New Busy is not the old busy. Search, chat and e-mail from your > inbox. > > N:WL:en-US:WM_HMP:042010_3 > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > 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.