我希望R打开在我的程序中创建的文件.我的代码使用以下代码将日志文件保存到名为logFile的变量中.
logFile <- sprintf("../output/%s_%s_output%sof%s.log", str1, str2, str3, str4);
Run Code Online (Sandbox Code Playgroud)
我试图通过调用来访问shell函数
shell('%s',logFile);
Run Code Online (Sandbox Code Playgroud)
但是我说错了
In shell("%s", toFile) : '%s' execution failed with error code 127
Run Code Online (Sandbox Code Playgroud)
如何在完成写入文件后让我的程序打开该文件?
你在找这样的东西吗?它工作得很好,至少在我的Windows机器上.
## An example temp file
ff <- paste0(tempfile(), ".txt")
write.table(head(mtcars), file=ff)
## Open the file with the program associated with its file extension
system2("open", ff)
Run Code Online (Sandbox Code Playgroud)