为什么Rstudio在用cat打印文本时多打印一行?

Why does Rstudio print an extra line when printing text with cat?

考虑这段代码:

{  
  cat("hello")
  Sys.sleep(1)
  cat("\rhi there!")
}

在终端和 Rstudio 中,我们看到单词 'hello' 后跟 'hi there!' 一秒后,但终端以 hi there!> 结尾,而 Rstudio 以 [= 换行结束12=]。有没有办法让两个系统就如何使用某些选项打印东西达成一致?或者这是 Rstudio 做的一些特别的事情?

试试

{  
  cat("hello")
  Sys.sleep(1)
  cat("\rhi there!\n")
}