【问题标题】:Concatenate strings and results in R plotmath在 R plotmath 中连接字符串和结果
【发布时间】:2013-08-20 12:50:10
【问题描述】:

在 R 中,我想在带有 Spearman rho 结果的情节中包含一个图例。我用这个:

expression(paste(rho, " = ", cor(v$V1, v$V2, method = 'spearman')))

但在传说中我得到:

p = cor($(v,V1), $(v,V2), spearman)

如何得到cor的结果?

【问题讨论】:

    标签: r plotmath


    【解决方案1】:

    这是一个应该有帮助的例子:

    set.seed(42)
    x <- 1:10
    y <- rnorm(10)
    plot(x,y)
    text(7,1, bquote(rho==.(cor(x,y, method="spearman"))))
    

    ?bquote 解释说它将评估.() 内的调用。一般不需要在plotmath 中使用paste

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-25
      • 2016-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多