最近 (2017) Windows 10 提供了一个完美运行的官方 Ubuntu 子系统(它不是虚拟机或像 Cywin 这样的应用程序)。 Windows 中的这个 Ubuntu 子系统提供了经典的 linux shell。
我在我的 Ubuntu 笔记本电脑中使用 system() 命令从 R 脚本使用 CDO(气候数据运算符)。
system(paste0("cd ~/Data/; cdo -f nc copy file1.grb2 file2.nc;"))
但我需要在 Windows 计算机上运行我的代码。
我之前问过如何在 Windows 中使用 R 中的这个 system() 命令:How can I call a Windows Terminal inside an R script?我了解到它与 Ubuntu 中的相同。
但我需要的是不同的:How to call the Ubuntu Shell in an R script in Windows 10?
我考虑过使用某种类型的组合,例如
System(some-command-that-calls-ubuntu-terminal())
最佳答案
您好,您可以尝试使用 wsl
命令。
wsl 代表 linux 的 windows 子系统,如果您在 cmd shell 中键入它,它将打开 linux shell。在 R 环境中(在 Windows 上)键入:
shell(cmd="wsl")
或者如果你想执行更多,例如
>shell(cmd="wsl ls")
Documents
Images
...
这有帮助吗?
关于r - Windows10 中来自 R 的 Ubuntu 终端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54092389/