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")
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?
The minus and hyphen sign are the same thing. A hyphen is a short, single-character line which connects word parts (i.e. ice-cream). A dash is a longer line—double the length of a hyphen—which indicates a break or an interruption in the thought. Dashes are used to set off part of a sentence.
the hyphen-minus (-, ASCII 45, next to the zero key) the en-dash (–, Unicode 2013, Alt+0151 on Windows) the em-dash (—, Unicode 2014, Alt+0150 on Windows)
Pressing the - on your keyboard, usually next to the 0 (zero) key, will produce a hyphen-minus.
Definition of minus sign : a sign − used in mathematics to indicate subtraction (as in 8−6=2) or a negative quantity (as in −10°) — called also negative sign.
Try backticks around CES-D
:
qplot(1:10, 1:10) + labs(x = expression(sqrt(`CES-D`~scores)), y = "CES-D scores")
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