【问题标题】:Include variable identifier in histogram title in R在 R 的直方图标题中包含变量标识符
【发布时间】:2014-04-20 23:24:44
【问题描述】:
for (i in 1:8){
  hist(x, main="Histrogram i")
}

是否可以对变量 i 求值,得到 8 个直方图,标题为“Histogram 1”、“Histogram 2”、...?

【问题讨论】:

    标签: r histogram title


    【解决方案1】:

    您必须使用paste 构造字符串。

    par(mfrow = c(2, 2))
    for (i in 1:4) {
      hist(rnorm(100), main = paste("Histogram", i))
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-18
      • 1970-01-01
      • 2017-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多