gpt4 book ai didi

r - 如何连续使用多个表达式

转载 作者:行者123 更新时间:2023-12-04 09:19:38 25 4
gpt4 key购买 nike

我是 R 的新手,我想弄清楚,如何在我的情节标题中写出诸如“这是我的 (\n)8 <=(小于或等于) x <= 10 的情节”之类的内容。
我试过这样的事情:

plot(1:10, main="Hey, guys, this is my plot for \n")
mtext(c(expression(8 <= x),expression(x <= 10), side=3)
这不完全是我想要的,而是“8(小于或等于)xx(小于或等于)10”,这两个表达式打印在主标题下方的一行中,(这很酷)但在同一个地方,这几乎没用:)
我也试过:
plot(1:10, main=bquote(paste(8 <= x, x <= 10, sep=",")))
什么样的我想要什么(除了分隔符似乎完全被忽略),但我不能添加更多的文字。输出:“8(小于或等于)xx(小于或等于)10”。
当我尝试
plot(1:10, main=paste("x",bquote(paste(x <= 8,z <= 10,sep=" ")),sep=" "))
输出完全激怒了我:标题是:“xpaste (\n) xx <= 8 (\n) xz <= 10 (\n) x”((\n)是换行符,其他字符完全相同打印什么)
那么是否有可能打印具有多个运算符的表达式?

最佳答案

heyTitle <- bquote(atop(
"Hey, guys, this is my plot for",
{8 <=x}*phantom()<=10
))

plot(1:10, main=heyTitle)

感谢 this answeratop()诡计。

编辑:这是图

编辑 2:从 another answer by G. Grothendieck 借用使用括号来固定间距。

enter image description here

关于r - 如何连续使用多个表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23519142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com