0

This is a very basic question and an already discussed topic here, but somehow none of the offered solutions seem to work for me: I simply want to write superscript in a vector of strings in brackets (as units).

I've tried expression(paste()) for example, but it doesn't work and I get errors for the additional brackets and ticks inside the string.

measure.labs <- c("VWC GS1 [V]", "Infiltration [ ]", "Precipitation [l m^-2]",)

Here, I would like to write "m^-2" with the "-2" in superscript. Is there a way to do this? Thank you!

KodakAsis
  • 57
  • 7
  • What are those brackets supposed to be? What exactly do you want this to look like? Where are you trying to use this vector? – MrFlick Oct 15 '19 at 14:45
  • 1
    I will assign the names to facet labels of a facet_wrap. The [ ] brackets are the brackets for the units of the parameters. In the end I want it to look exactly like it does now, only with the "-2" in superscript (and the "^" invisible, of course, it was only what I used to try superscripting). – KodakAsis Oct 15 '19 at 14:54
  • 1
    Something like `plot(1,1,main=expression("Precipitation " * group("[", l * m^-2 , "]")))`? – MrFlick Oct 15 '19 at 15:02
  • Yes but I use facet_wrap and change the label names using a named vector (measure.labs) with "labeller(measurement=measure.labs)" – KodakAsis Oct 15 '19 at 15:32
  • Well, if that's what you use, it would help if you included a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) that can be used for testing. – MrFlick Oct 15 '19 at 15:40
  • So its not possible to superscript inside the vector I've provided, I have to do it in ggplot/ the facet_wrap call itself? I will work out a reproducible example for that. – KodakAsis Oct 15 '19 at 15:48

0 Answers0