本文介绍了如何等待R中的按键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想暂停我的R脚本,直到用户按下一个键.

I want to pause my R script until the user presses a key.

我该怎么做?

推荐答案

正如已经在评论中写过某人一样,您不必在readline()之前使用猫.只需写:

As someone already wrote in a comment, you don't have to use the cat before readline(). Simply write:

readline(prompt="Press [enter] to continue")

如果您不想将其分配给变量并且不想在控制台中打印退货,请将readline()包裹在invisible()中:

If you don't want to assign it to a variable and don't want a return printed in the console, wrap the readline() in an invisible():

invisible(readline(prompt="Press [enter] to continue"))

这篇关于如何等待R中的按键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 08:01