【问题标题】:Ubuntu terminal from R in Windows10Windows10 中 R 的 Ubuntu 终端
【发布时间】:2019-06-03 04:19:52
【问题描述】:

最近(2017 年)Windows 10 提供了一个可以完美运行的官方 Ubuntu 子系统(它不是虚拟机或像 Cywin 这样的应用程序)。 Windows 中的这个 Ubuntu 子系统提供了经典的 linux shell。

我正在使用 system() 命令在我的 Ubuntu 笔记本电脑中的 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 中相同。

但我需要的是不同的:如何在 Windows 10 的 R 脚本中调用 Ubuntu Shell?

我考虑过使用某种类型的组合,例如

System(some-command-that-calls-ubuntu-terminal())

【问题讨论】:

    标签: r windows shell ubuntu terminal


    【解决方案1】:

    您好,您可以尝试使用wslcommand。 wsl 代表 linux 的 windows 子系统,如果您在 cmd shell 中键入它,它将打开 linux shell。在 R 环境中(在 Windows 上)输入:

    shell(cmd="wsl")
    

    或者如果你想执行更多,例如

    >shell(cmd="wsl ls")
    Documents
    Images
    ...
    

    这有帮助吗?

    【讨论】:

      猜你喜欢
      • 2018-01-24
      • 2021-03-01
      • 2017-03-20
      • 2020-06-01
      • 1970-01-01
      • 2018-04-09
      • 2018-07-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多