【问题标题】:Simple loop doen't show the result to output in R [duplicate]简单循环不显示在 R 中输出的结果 [重复]
【发布时间】:2018-09-26 20:59:08
【问题描述】:

我在 Rstudio 中用 R 写了一个简单的循环

it=10:110
for(i in it)
{
  sprintf("partial r2 for iteration %f is %f....",i,0.0)
}

但是上面的代码没有在控制台提示结果?

【问题讨论】:

    标签: r


    【解决方案1】:

    您必须将sprintf() 包裹在cat()message() 中,如下所示:

    it=10:110
    for(i in it)
    {
      cat(sprintf("partial r2 for iteration %f is %f....",i,0.0))
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-13
      • 2014-12-23
      • 2020-06-09
      相关资源
      最近更新 更多