How about using paste() inside the jpeg() function to append a '.jpg' to the end of your species name? See the change below. I also added a dev.off() to close the newly created jpeg.
species.name="CussoniaHolstii" dia<-10:100 biomass = -21.4863 + 0.5797 * (dia ^ 2) biomass jpeg(paste(species.name, '.jpg', sep = '') plot (biomass, main=species.name, xlab="dbh in cm", ylab="biomass in kg") dev.off() On Tue, Apr 12, 2011 at 9:54 PM, Benjamin Caldwell <btcaldw...@berkeley.edu>wrote: > Evening folks, > > I'm trying to print a series of graphs to .jpeg using a variable as the > title, but run into the difficultly that I can't find a way to append the > file extension to the .jpeg (in this case extensionless!) files. > > Example: > ---- > species.name="CussoniaHolstii" > dia<-10:100 > biomass = -21.4863 + 0.5797 * (dia ^ 2) > biomass > jpeg(species.name) > plot (biomass, main=species.name, xlab="dbh in cm", ylab="biomass in kg") > ----- > The output is CussoniaHolstii, but I want CussoniaHolstii.jpg. The help > file > for jpeg() specifies that the name include the extension (e.g. > jpeg("CussoniaHolstii.jpg") but then I'd have to input the file name each > time. > > Any help or workaround much appreciated. > * > * > *Ben Caldwell* > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > -- ___________________________ Luke Miller Postdoctoral Researcher Marine Science Center Northeastern University Nahant, MA (781) 581-7370 x318 [[alternative HTML version deleted]] ______________________________________________ R-help@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.