none
Microsoft R not compatible withe OneDrive for Business directory names. RRS feed

  • Question

  • I'm using Microsoft R 3.3.1 under Windows 10, and am experiencing a problem with using R and Microsoft OneDrive for Business.

    Consider the following:

    > dir()
    ...
    [31] "OneDrive – Innherred Samkommune"
    ...
    > setwd(dir()[31])
    > setwd("..")
    > setwd("OneDrive – Innherred Samkommune")
    Error in setwd("OneDrive – Innherred Samkommune") : 
    cannot change working directory
    > p <- getwd(dir()[31])
    > r <- "OneDrive – Innherred Samkommune"
    > p
    [1] "OneDrive – Innherred Samkommune"
    > r
    [1] "OneDrive – Innherred Samkommune"
    > p == r
    [1] FALSE

    It turns out that substr(p,10,10) does not match substr(r,10,10). That's the "-". But behold:

    > pp <- substr(p,10,10)
    > rr <- substr(r,10,10)
    > pp == rr
    [1] FALSE
    > charToRaw(pp)
    [1] 96
    > charToRaw(rr)
    [1] 96

    Inspecting this from the shell, it seems that there are no problems with "-" in directory names when the - is typed from the keyboard. It seems that the "-" in the OneDrive directory name is internally represented by an en dash or somwthing, but that R externally displays it as a hyphen and gets confused.

    Is this solvable in any way? The obvious solution is to not use OneDrive for RStudio projects, which by all means works fine. But somehow I'd like for it to be possible.

    Any and all suggestions welcome.

    Thank you.


    Thursday, January 12, 2017 12:08 PM

All replies

  • You should be able to setwd() to any directory path that you could normally 'CD' to at a command prompt. In this case it looks like you need to include the userprofile path in the full spec for OneDrive, e.g.

    C> cd "OneDrive - Microsoft"
    The system cannot find the path specified.

    Whereas when you include the userprofile path, e.g. "C:\Users\rkittler":

    C> cd "C:\Users\rkittler\OneDrive - Microsoft"

    C> cd
    C:\Users\rkittler\OneDrive - Microsoft

    and in R:

    > setwd("C:\\Users\\rkittler\\OneDrive - Microsoft\\Data")
    > getwd()
    [1] "C:/Users/rkittler/OneDrive - Microsoft/Data"

    Hence make sure you can get to that directory from the command prompt before trying the path in R.

    Thursday, January 12, 2017 3:14 PM
  • Hi, I'm trying to do the same for shinyapp.io, the error is "error in gzfile: no se puede abrir la conexión" and it says not such a file directory, so Do u have any ideas?
    Monday, August 3, 2020 8:41 PM