在RStudio中转义readLines()函数

bos*_*ski 5 console r rstudio

由于我使用R所做的工作,因此需要使用该readline()功能输入文本。当有时,而不是书面方式这个问题是readline()我跑readLines()意外(因为自动完成或无论何种原因)。

一旦运行readLines(),便无能为力了。我可以继续写,但是不能在控制台中恢复提示(无法运行任何代码),因为我不知道如何关闭readLines()函数调用。有什么线索吗?

请注意,此问题仅在RStudio中发生(根据Matt的评论,在Visual Studio中也是如此)。

在此处输入图片说明

Mat*_*att 1

不是一个完美的修复,但你可以使用debug(). 每当您意外拨打电话readLines()时,只需browse[2]输入即可退出Q

debug(readLines)
readline()
asdf
Run Code Online (Sandbox Code Playgroud)

[1] "asdf"

readLines()
debugging in: readLines()
debug: {
    if (is.character(con)) {
        con <- file(con, "r")
        on.exit(close(con))
    }
    .Internal(readLines(con, n, ok, warn, encoding, skipNul))
}
Run Code Online (Sandbox Code Playgroud)

Browse[2]> Q

readline()
asdf
Run Code Online (Sandbox Code Playgroud)

[1] "asdf"