简体   繁体   中英

paste0 regular and italicized text in R

I need to concatenate two strings within an R object: one is just regular text; the other is italicized. So, I tried a lot of combinations, eg

paste0(" This is Regular", italic( This is Italics))

The desired result should be:

This is Regular This is Italics

Any ideia on how to do it?

Thanks!

In plot labels, you can use expressions, see mathematical annotation :

 plot(1,xlab=expression("This is regular"~italic("this is italic")))

在此处输入图像描述

To provide an string for which an HTML parser will recognise the need to render the text in Italics, wrap the text in <i> and </i> . For example: "This is plain text, but <i>this is in Italics</i>." .

However, most HTML processors will assume that you want your text to appear as-is and will escape their input by default. This means that the special meanings of certain characters - including < and > will be "turned off". You need to tell the processor not to do this. How you do that will depend on context. I can't tell you that because you haven't given me context.

Are you for example, writing to a raw HTML file? (You need do nothing.) Are you writing to a Markdown file? If so, how? In plain text or in a rendered chunk? Are you writing a caption to a graphic? (Waldi has suggested a solution.) Etc, etc....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM