如何在 R 中执行 scp?

How to do scp in R?

我想知道 scp 是否喜欢:

scp localmachine/path_to_the_file username@server_ip:/path_to_remote_directory

可以使用 R 代码吗?换句话说,要在 R 中复制本地机器中的文件,可以使用 file.copy,将文件从本地机器复制到远程机器的 R 可能性是多少?

有包 ssh.utils 将 ssh 命令包装在 R 函数中。

因此您的示例将变为:

library(ssh.utils)
cp.remote(remote.src = "", 
          remote.dest = "username@server_ip", 
          path.src = "localmachine/path_to_the_file",
          path.dest = "path_to_remote_directory")

编辑:我可以安装它,但无论如何它不是很灵活,因为它不接受选项...

对于系统命令,这将是:

system("scp localmachine/path_to_the_file username@server_ip:/path_to_remote_directory")