[R] Constructing arguments for plotmath
Dennis Fisher
fisher at plessthan.com
Sun Aug 1 17:03:41 CEST 2010
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.
Dennis
(R 2.11; OS X [platform should not be an issue here])
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com
More information about the R-help
mailing list