Can R read from a file through an ssh connection?

前端 未结 1 357
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-05 07:34

R can read files on a web server using convenient syntax such as

data <- read.delim(\"http://remoteserver.com/file.dat\")

I wonder if th

相关标签:
1条回答
  • 2020-12-05 08:16

    You can read a file using pipes like this:

    d = read.table( pipe( 'cat data.txt' ), header = T )
    

    If you wanted to read from an SSH connection, try this:

    d = read.table( pipe( 'ssh hostname "cat data.txt"' ), header = T )
    

    There's also no reason to confine this to just ssh commands, you could also do something like this:

    d = read.table( pipe( 'cat *.txt' ) )
    

    See the R Data Import/Export page for more information, specifically the Connections section.

    0 讨论(0)
提交回复
热议问题