Rscript file path with space

后端 未结 4 1217
情话喂你
情话喂你 2020-12-21 00:46

I am trying to run the following R script in windows shell:

Rscript C:/Documents/Folder name containing space/myscript.txt

In this case I g

4条回答
  •  孤城傲影
    2020-12-21 01:22

    Forward slashes work just fine with R, so don't worry about backward slashes. I've just verified and the following works at the CMD.exe terminal of Windows 8.1:

    C:\Windows\System32> Rscript "C:/Users/hb/folder with spaces/script.R"
    [1] "1+2+3"
    
    C:\Windows\System32>
    

    My best guess is that you've got the pathname incorrect. If it's a non-existing pathname, you do get:

    C:\Windows\System32> Rscript --vanilla "C:/Users/hb/folder with spaces/non-existing.R"
    Fatal error: cannot open file 'C:/Users/hb/folder with spaces/non-existing.R': No such file or directory
    

    You can validate it from within R, e.g.

    > file.exists("C:/Users/hb/folder with spaces/script.R")
    [1] TRUE
    

提交回复
热议问题