I am trying to label a plot with the following label:
"Some Assay EC50 (uM)" where the "u" is a micro symbol.
I currently have:
assay <- "Some Assay" plot(0,xlab=expression(paste(assay," AC50 (",mu,"M)",sep="")))
But that gives: "assay EC50 (uM)" rather than the desired "Some Assay EC50 (uM)".
Suggestions? Thanks.
I also tried:
paste(assay,expression(paste(" AC50 (",mu,"M)",sep="")),sep="")
Create an Expression in R Programming – expression() Function. expression() function in R Language is used to create an expression from the values passed as argument. It creates an object of the expression class.
bquote() function in R Language is used to quote the arguments passed to it, except the values which are wrapped in '. ()'. It evaluates the wrapped values and quotes the result.
A variable in R can be defined using just letters or an underscore with letters, dots along with letters. We can even define variables as a mixture of digits, dot, underscore and letters.
You want a combination of bquote()
and a bit of plotmath fu:
assay <- "Some Assay" xlab <- bquote(.(assay) ~ AC50 ~ (mu*M)) plot(0, xlab = xlab)
The ~
is a spacing operator and *
means juxtapose the contents to the left and right of the operator. In bquote()
, anything wrapped in .( )
will be looked up and replaced with the value of the named object; so .(assay)
will be replaced in the expression with Some Assay
.
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