I can't find a way how to write subscripts in the title or the subtitle in R. How can I write v 1,2 with 1,2 as subscripts?
Thanks for your help!
Subscripts and Superscripts To indicate a subscript, use the underscore _ character. To indicate a superscript, use a single caret character ^ . Note: this can be confusing, because the R Markdown language delimits superscripts with two carets.
R doesn't actually have scalar types; everything is a vector, so subscripts are vectors. In the expression x[2] , the subscript is a vector containing a single element equal to 2. But you could use the vector (2, 3) as a subscript of x , and you'd get (1, 4).
To add superscript as a title add bquote function with value inside ggtitle(). Parameter : like xlab and ylab functions, we can give the title for plot directly using this function. Here we will bquote() function for writing Superscript value ( Number VS Number2 ) as a title of plot.
To set labels for X and Y axes in R plot, call plot() function and along with the data to be plot, pass required string values for the X and Y axes labels to the “xlab” and “ylab” parameters respectively. By default X-axis label is set to “x”, and Y-axis label is set to “y”.
expression
is your friend:
plot(1,1, main=expression('title'^2)) #superscript plot(1,1, main=expression('title'[2])) #subscript
If you are looking to have multiple subscripts in one text then use the star(*) to separate the sections:
plot(1:10, xlab=expression('hi'[5]*'there'[6]^8*'you'[2]))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With