7

I'm using expression() in my plot's x-axis label to create a square-root symbol over my measure's name to indicate that the data has been transformed using square-root transformation. However, my measure's name ("CES-D") has a hyphen in it. When I write it in the expression(), the hyphen becomes a minus or en dash character with space around it.

qplot(1:10, 1:10) + 
    labs(x = expression(sqrt(CES-D~scores)), 
         y = "CES-D scores")

Hyphens different in x and y axis labels

Notice the hyphens are different in the x and y axis labels. In the x-axis label, it looks like square root of "CES minus D scores".

How do I make a regular hyphen character inside an expression() for text?

alistaire
  • 42,459
  • 4
  • 77
  • 117
LC-datascientist
  • 1,960
  • 1
  • 18
  • 32

1 Answers1

9

Try backticks around CES-D:

qplot(1:10, 1:10) + labs(x = expression(sqrt(`CES-D`~scores)), y = "CES-D scores")
neilfws
  • 32,751
  • 5
  • 50
  • 63