gpt4 book ai didi

linux - 在 R 中执行 system() 后获取终端输出

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:21:13 24 4
gpt4 key购买 nike

如果我运行一个包含类似于以下系统函数调用的 R 脚本:

x<-system("ls -t -r | tail -n 1") , 

如果命令正确执行,x 将为 0,如果有错误则不同于 0。如何在执行脚本时将终端的输出保存在 R 中?

最佳答案

intern 属性设置为 true。

x<-system("ls -t -r | tail -n 1", intern=TRUE)

关于linux - 在 R 中执行 system() 后获取终端输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9825763/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com