How to read files from a UNC-specified directory in R?

前端 未结 3 1309
感情败类
感情败类 2021-01-06 03:48

Is it possible to read files from a UNC-specified directory in R? I\'d like to do it without using any packages beyond the base installation.

相关标签:
3条回答
  • 2021-01-06 04:14

    UNC names work fine, you just have to escape them correctly. This works for me:

    read.csv('\\\\COMPUTER\\Directory\\file.txt')
    
    0 讨论(0)
  • 2021-01-06 04:14

    a slightly more cross-platform approach

    # the two '' are required to represent the two leading slashes of the UNC path
    read.csv(file.path('', '', 'COMPUTER', 'Directory' 'file.txt'))
    
    0 讨论(0)
  • 2021-01-06 04:15

    adding to nograpes answer ... you can avoid the escaping ugliness by using forward slashes ... this works as well

    read.csv('//COMPUTER/Directory/file.txt')
    
    0 讨论(0)
提交回复
热议问题