【问题标题】:How to add >-sign to expression in R?如何将 >-sign 添加到 R 中的表达式?
【发布时间】:2014-07-28 04:10:39
【问题描述】:

我想在轴标签上添加一个“大于”符号。 显示的文本应为cumulated frequency p(>p[f]))

我尝试过(其中包括):

title(mgp=c(2.50, 1, 0), cex.lab=1.25, xlab = expression("cumulated frequency" ~ p(>p[f]))) # xlab

但我的试验都没有奏效 - 错误在哪里?没有> 它可以正常工作:

title(mgp=c(2.50, 1, 0), cex.lab=1.25, xlab = expression("cumulated frequency" ~ p(p[f]))) # xlab

【问题讨论】:

    标签: r expression plotmath


    【解决方案1】:

    > 是二元运算符。因此,它的左侧需要一些东西。例如“虚拟”-null-label {}:

    plot(1:10, 1:10, xlab=expression("frequency"~p({}>p[f])))
    

    还有,例如phantom()plain()等可用于打印“无”。

    如果您不想在 < 周围有空格,请尝试:

    plot(1:10, 1:10, main=expression("test"~p(paste(">",p[f]))))
    

    或者更“数学”的<

    plot(1:10, 1:10, main=expression("test"~p(paste(symbol(">"),p[f]))))
    

    【讨论】:

    • 还有没有办法去掉>-sign前后的空格?使用 RichardScrivens 解决方案我可以做到,但文本模式中的 >-sign 看起来很难看。并且在 plotmath-mode 中添加了空间,...
    • 在您的第二个解决方案中,就像 RichardScriven 的一个。 > 比您的第一个解决方案中的要大得多。如果没有空格的小> 会很高兴,... :)
    • @R_User:symbol(">") 怎么样 - 这给出了一个更像“数学符号”的 >
    【解决方案2】:

    这可能对你有用:

    plot.new()
    title(mgp = c(2.50, 1, 0), cex.lab = 1.25, 
          xlab = expression(paste("cumulated frequency p(>", p[f], ")")))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-29
      • 1970-01-01
      • 2017-01-31
      • 1970-01-01
      • 1970-01-01
      • 2018-12-13
      • 1970-01-01
      相关资源
      最近更新 更多