day*_*yne 29 expression r
我试图用以下标签标记一个情节:
"一些分析EC50(uM)",其中"u"是微观符号.
我目前有:
assay <- "Some Assay"
plot(0,xlab=expression(paste(assay," AC50 (",mu,"M)",sep="")))
Run Code Online (Sandbox Code Playgroud)
但这给出了:"测定EC50(uM)"而不是所需的"某些测定EC50(uM)".
建议?谢谢.
我也尝试过:
paste(assay,expression(paste(" AC50 (",mu,"M)",sep="")),sep="")
Run Code Online (Sandbox Code Playgroud)
Rei*_*son 45
你想要一个bquote()
和一些plotmath fu 的组合:
assay <- "Some Assay"
xlab <- bquote(.(assay) ~ AC50 ~ (mu*M))
plot(0, xlab = xlab)
Run Code Online (Sandbox Code Playgroud)
这~
是一个间距操作符,*
意味着将内容并置在操作员的左侧和右侧.在bquote()
,.( )
将查找包含的任何内容并替换为命名对象的值; 所以.(assay)
将在表达式中替换为Some Assay
.
使用 tidy_eval 方法你可以做
library(rlang)
assay <- "Some Assay"
plot(0,xlab=expr(paste(!!assay," AC50 (",mu,"M)",sep="")))
Run Code Online (Sandbox Code Playgroud)
表达式和!! 包含在 tidyverse 中,因此您实际上不需要加载 rlang。我把它放在那里只是为了明确它们来自哪里。