相关疑难解决方法(0)

获取最后一个顶级命令作为字符串

有没有办法将最后一个顶级命令存储到一个字符串中而不将历史记录保存到文件中并将其读回以获取最后一个命令?我有代码

lastcmd <- function(){
    tmp <- tempfile()
    savehistory(tmp)

    # If we call this function then that call will
    # be the last line in the history so we want the one
    # before that
    tail(readLines(tmp), 2)[1]
}
Run Code Online (Sandbox Code Playgroud)

这不是太糟糕但我想知道是否有办法在没有先写入文件的情况下将历史记录作为字符.

r

11
推荐指数
1
解决办法
274
查看次数

标签 统计

r ×1