r - Windows10 中来自 R 的 Ubuntu 终端

标签 r windows shell ubuntu terminal

最近 (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/

相关文章:

windows - 如何对 Inno Setup 生成的卸载文件进行数字签名?

c++ - 为来自不同进程的窗口设置父级是否正确?

Linux:查看目录中的文件数

linux - mkdir : cannot create directory ‘data’ : File exists

R Beta 函数 - 相对 y 尺度

linux - 使用 Windows 批处理命令从环境变量中提取 IP 地址和端口号

c++ - Rcpp Armadillo : Using autoconf to disable OpenMP

linux - linux中如何删除超过n天的文件和目录

r - fviz_cluster() 不接受 k-medoid (PAM) 结果

r - 使用 matlab 计算多变量情况下的偏正态分布