2

Recently (2017) Windows 10 provides an official Ubuntu subsystem that works perfectly (It is not a Virtual Machine or an app like Cywin). This Ubuntu subsystem inside Windows provides the classic linux shell.

I am using CDO (Climate Data Operators) from an R script in my Ubuntu laptop using the system() command.

system(paste0("cd ~/Data/; cdo -f nc copy file1.grb2 file2.nc;"))

but I need to run my code in Windows computers.

I asked before how to use this system() command from R inside Windows here: How can I call a Windows Terminal inside an R script? and I learned that it is the same as in Ubuntu.

But what I need is different: How to call the Ubuntu Shell in an R script in Windows 10?

I've thought about using some type of composition like

System(some-command-that-calls-ubuntu-terminal())
Forever
  • 385
  • 3
  • 16

1 Answers1

2

Hi you can try with the wslcommand. wsl stands for windows subsystem for linux and if you type it in a cmd shell it will open the linux shell. In an R environment (on Windows) type:

shell(cmd="wsl")

Or if you want to execute more, e.g.

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

Does this help?

Marco De Virgilis
  • 982
  • 1
  • 9
  • 29