2

I have an R script that I would like to run from the command line using Rscript.exe in Windows. The script runs fine if I open it in RStudio but when I run it through Rscript in the command line it fails because I have UNC paths in my script. For example,

read.csv("//server/directory/file.csv/")

Rscript fails and says the directory does not exist. Is there anyway to resolve this problem?

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
rjss
  • 935
  • 10
  • 23
  • Does `read.csv("//server/directory/file.csv")` work? If not can you give your code so that we can reproduce it? (I am not sure whether you need `normalizePath` at all) – Christoph Jun 08 '16 at 12:31
  • @Christoph ```read.csv("//server/directory/file.csv")``` works. I have tried my script with only that line and get the same error. To be clearer, if I run the script from RStudio it works; however if I try to run it from the command line using ```Rscript myscript.R``` then I get an error. – rjss Jun 08 '16 at 12:51
  • Can you post a reproducible example `myscript.R`? – Christoph Jun 08 '16 at 13:09
  • I am not able to add a reproducible example because the path is not public but on further inspection the problem is with permission to the directories and not with Rscript. As a note for future readers of this post; I can confirm that I can use Rscript with UNC paths. – rjss Jun 08 '16 at 13:23

0 Answers0