[R] expression

William Dunlap wdunlap at tibco.com
Mon Apr 1 22:59:49 CEST 2013


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]]



More information about the R-help mailing list