Hi all, I´m using titt<- expression(paste("R con ventanas de 200 ", italic(datos))) And it works properly on a plot(...,main=titt,..) But if I want to add an improvement to avoid typing n on the plot so that n<-200 titt<- expression(paste("R con ventanas de ",n, italic(datos))) It doesn´t recognize that n is a "variable" and adds "n" letter instead of 200 on the plot when run: plot(...,main=titt,..) How can I include n in the plot authomatically without loosing the italic letter? [[alternative HTML version deleted]]
?plotmath tells you how. -- Bert On Mon, Apr 1, 2013 at 12:46 PM, Jose Narillos de Santos <narillosdesantos at gmail.com> wrote:> Hi all, > > I? using > > > titt<- expression(paste("R con ventanas de 200 ", italic(datos))) > > And it works properly on a plot(...,main=titt,..) > > But if I want to add an improvement to avoid typing n on the plot so that > > n<-200 > > titt<- expression(paste("R con ventanas de ",n, italic(datos))) > > It doesn? recognize that n is a "variable" and adds "n" letter instead of > 200 on the plot when run: > > plot(...,main=titt,..) > > How can I include n in the plot authomatically without loosing the italic > letter? > > [[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. >-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
Use bquote(), as in n <- 200 titt <- bquote(paste("R con ventanas de ", .(n), " ", italic(datos))) or, using ~ instead of paste(), titt <- bquote("R con ventanas de " ~ .(n) ~ italic(datos)) plot(1, 1, main=titt) The notation .(xxx) means to replace xxx by the value of the variable called "xxx". You can also use bquote() instead of expression in the simple (no variables) case. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf > Of Jose Narillos de Santos > Sent: Monday, April 01, 2013 12:46 PM > To: r-help > Subject: [R] expression > > Hi all, > > I?m using > > > titt<- expression(paste("R con ventanas de 200 ", italic(datos))) > > And it works properly on a plot(...,main=titt,..) > > But if I want to add an improvement to avoid typing n on the plot so that > > n<-200 > > titt<- expression(paste("R con ventanas de ",n, italic(datos))) > > It doesn?t recognize that n is a "variable" and adds "n" letter instead of > 200 on the plot when run: > > plot(...,main=titt,..) > > How can I include n in the plot authomatically without loosing the italic > letter? > > [[alternative HTML version deleted]]
On 2013-04-01 12:46, Jose Narillos de Santos wrote:> Hi all, > > I?m using > > > titt<- expression(paste("R con ventanas de 200 ", italic(datos))) > > And it works properly on a plot(...,main=titt,..) > > But if I want to add an improvement to avoid typing n on the plot so that > > n<-200 > > titt<- expression(paste("R con ventanas de ",n, italic(datos))) > > It doesn?t recognize that n is a "variable" and adds "n" letter instead of > 200 on the plot when run: > > plot(...,main=titt,..) > > How can I include n in the plot authomatically without loosing the italic > letter?titt <- bquote("R con ventanas de " ~ .(n) ~ italic(datos)) and I usually find it much more flexible to add the title with a separate title(titt) call. Peter Ehlers