I am trying to create a text layer in an R plot containing normal and superscript text that derives from variables.
So far I have this:
first = c("one", "two", "three")
second = c(1, 2, 3)
plot(1:3, 3:1)
text(1:3, 3:1, labels=first)
The way it works now, it shows one, two, etc on the plot. I want it to show one1, two2, etc.
I guess it should be some combination of expression
, paste
, bquote
and maybe another function. I just can't get it to get it to read the data as vectors and make the proper superscript.
I've seen some questions on this site, for example:
- Combining paste() and expression() functions in plot labels
- Use expression with a variable r
- Including variables in expression call in R
None of them fully answer my question.