首页 > 解决方案 > R 找不到 shell.exec (Mac OSX)

问题描述

我是 R 和 RStudio 的新手;在 Mac OSX 10.15.7 中使用它们。我正在尝试运行一个用户编写的程序来执行一些统计数据并将结果输出到预先组织的 excel 电子表格中,该电子表格以特定的方式将它们可视化。

该程序无法在我的机器上运行,但显然可以在程序作者的机器上运行(我与他们交谈过)。

当我运行程序时,我收到以下错误:

Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
[1/2] Analysing proc traj outcomes
[2/2] Writing output file
Error in shell.exec(output_file) : could not find function "shell.exec"

我搜索了提到 shell.exec 的语法,发现以下内容:

 step <- step + 1
        cat(paste0("[", step, "/", total, "] Writing output file\n"))
        if (xlsx_output){
                create_excel(bic_df, prob_df)
                if (open_file){
                        shell.exec(file.path(output_file))
                }
        } else{
                create_txt(bic_df, prob_df)
                if (open_file){
                        shell.exec(output_file)
                        shell.exec(output_txt)
                }
        }

我为这个问题的新手道歉。欢迎任何建议。

谢谢

标签: rmacosshellunix

解决方案


shell.execshell.exec(x)是 R 中仅适用于 Windows 的命令。在 MacOS 上最接近的是system2("open", x). 但是,运行它时发生的情况可能会有所不同,因为它取决于系统上的文件关联,因此不能保证它是完全等价的。


推荐阅读