Subscripts in R when adding other text

前端 未结 2 785
野的像风
野的像风 2021-01-11 15:26

How would you add a subscript to one particular word of a title in R? For example, suppose the title is \"A_2 and B_2.\" How would you add these two subscripts?

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-11 16:04

    You do not need paste (or quotes for that matter) at all:

    expression( A[2]~and~B[2] )
    

    Test:

    plot(1,1, main=expression( A[2]~and~B[2] ) )
    

    The syntactic principle is that tildes (which creates a space) and asterisks (non-space plotmath separator) are used to separate items and that no quotes are needed unless you are using a plotmath function name .... such as wanting the word "paste" or "sqrt" to appear in the displayed version of the expression.

提交回复
热议问题