如何从 R 脚本调用 linux 终端代码 [英] How to call linux terminal code from R script

查看:44
本文介绍了如何从 R 脚本调用 linux 终端代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是:

我知道这可能是一个愚蠢的问题...我的 R 代码在这里:

I know it can be a silly question... my R code is here:

download.file('https://some.dir,
              destfile = '/home/myfile.grb2',method='auto',quiet = FALSE,
              mode="wb", cacheOK = TRUE)

下载后,我必须使用来自终端的代码转换该文件......但我需要这是自动的.转换器代码是这样的:

after the download, I had to convert that file using a code from terminal... but I need this to be automatic. The converter code is this:

source activate ncl_stable
cd /home
ncl_convert2nc myfile.grb2

谷歌搜索我看到 Linux 终端 使用 C++.我知道有一个包可以在 R 中运行 C++ 代码,Rcpp,但它像 linux 终端一样工作?

Googling I saw that Linux Terminal uses C++. I know there is a package to run C++ codes in to R, Rcpp, but it works like the linux terminal?

推荐答案

这样做可以解决问题:

system(paste0("source activate ncl_stable;cd /home;ncl_convert2nc myfile.grb2"))

您可以在此处找到更多信息此处.

这篇关于如何从 R 脚本调用 linux 终端代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆