Hi, Try this,
library(grid) value <- c(0.1) lab <- c("test", expression(bquote(paste(.(value[1]*100), " and percentiles1", sep=""))), bquote(expression(.(value[1]*100)*" and percentiles2")), bquote(paste(.(value[1]*100), " and percentiles3", sep="")) ) grid.newpage() grid.text(eval(lab[1]), x=0.5, y=unit(1,"npc")-unit(1,"lines")) grid.text(eval(lab[2]), x=0.5, y=unit(1,"npc")-unit(2,"lines")) grid.text(eval(lab[3]), x=0.5, y=unit(1,"npc")-unit(3,"lines")) grid.text(lab[4], x=0.5, y=unit(1,"npc")-unit(4,"lines")) My preference goes for the last one. HTH, baptiste 2009/9/2 Sebastien Bihorel <sebastien.biho...@cognigencorp.com> > Dear R-users, > > I am trying to use the grid.text and expression functions to display > several character strings and plotmath text on a viewport. Some strings can > include a variable portion (PI.limits in the following example), which I > thought could be implemented by combining the bquote and the expression > functions. Unfortunately, my expressions do not seem to be evaluated. I > would greatly appreciate if somebody could tell me where my mistake(s) > is(are). > > Thank you in advance > > > ###### 8< ####### > > library(grid) > > PI.limits <- c(0.1,0.9) > > vp.ref <- c("raw data","median","median", > bquote(expression(paste(.(PI.limits[1]*100), " and ", > .(PI.limits[2]*100)^th," > percentiles", sep=""))), > bquote(expression(paste(95^th,"confidence interval on > percentiles", sep=" "))), > bquote(expression(paste(95^th,"confidence interval on > percentiles", sep=" "))) > ) > > > grid.newpage() > > for (i in c(1,3,4,5,6)) { > grid.text(eval(vp.ref[i]), x=0.5, y=unit(1,"npc")-unit(i,"lines")) > } > > ______________________________________________ > 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. > -- _____________________________ Baptiste AuguiƩ School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK http://newton.ex.ac.uk/research/emag ______________________________ [[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.