On Sun, Aug 1, 2010 at 11:03 AM, Dennis Fisher <fis...@plessthan.com> wrote: > Colleagues, > > I am encountering difficulty adding formatted text to a graphic. > Specifically, I want to add a superscript in the middle of a text string but > I would like to format the text string on the fly. The commands: > plot(1,1) > ARG <- bquote('TEXT'^'\u00ae') > mtext(ARG, line=-2, side=1) > yield the desired output. > > However, my goal is to paste together a string, then pass it to mtext. For > example: > plot(1,1) > PART1 <- 'TEXT' > PART2 <- '^' > PART3 <- '\u00ae' > ARG <- paste(PART1, PART2, PART3) > mtext(bquote(.(ARG)), line=-2, side=1) ## bquote(ARG) also > does not work > This does not work -- the unprocessed string: > TEXT ^ ® > is printed. > > Obviously, I don't understand some aspect of passing arguments to bquote. Of > note, I tried "expression" instead of bquote but I was not able to get the > registered sign ('\u00ae') to appear as a superscript. > > Any help would be appreciated.
Try this (noting the backquotes around \u00ae since otherwise its not a valid R name): x <- "TEXT^`\u00ae`" plot(0, main = parse(text = x)) ______________________________________________ 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.