[R] Inserting superscripts in free-format text line
David Winsemius
dwinsemius at comcast.net
Wed Aug 22 06:11:04 CEST 2012
On Aug 21, 2012, at 10:39 AM, Peter Ehlers wrote:
> On 2012-08-21 08:28, Brian Kriegler wrote:
>> All of these suggestions are great. Let me add one other dimension.
>> Suppose I want to add curly quotations, italicize, underline, or
>> bold
>> some of the words. I can get this to work:
>>
>> plot(-15:15,15:-15, pch=NA)
>> text(x=0, y=5,
>> expression
>> (bold
>> (This
>> )~is~a~underline(test)^1~of~the~italic(Emergency)~Broadcast~System.))
>>
>>
>>
>> I can also get this to work:
>>
>>
>> text(x=0, y=-5, dQuote("This is another test."))
>>
>> But, I've wrestled getting curly quotes to work within expression().
>>
>> Any suggestions are greatly appreciated.
>>
>> -Brian
>
> [....]
>
> Font issues can be system-dependent. The following works for me on
> Windows.
>
> Insert unicode characters in the appropriate places. For example,
> to place double quotes around the word 'Broadcast' in your
> example above:
>
> text(0, 5, expression(....~"\u201c"*Broadcast*"\u201d"~System))
This would be a way to make that expression somewhat more "symbolic"
by defining the special characters outside the expression and then
using the bquote and .() functions:
qql <- "\u201c"
qqr <- "\u201d"
plot(0:10,0:10)
text(5, 5.5, bquote(Emergency~ .(qql)*Broadcast*.(qqr)~System))
That's nice because it opens up the possibilty of accessing other
object values as well.
>
> Don't forget the '*' to concatenate the quote symbols with the word.
>
> Peter Ehlers
>
--
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list