Relief from backslash irritation in R for Windows

前端 未结 9 2365
没有蜡笔的小新
没有蜡笔的小新 2021-02-10 10:41

Early in my R life I discovered the pain of R and windows being on different pages when it came to the separator between directories and subdirectories. Eventhough I know about

9条回答
  •  自闭症患者
    2021-02-10 11:31

    why not create a function that checks the OS and returns the proper file separator (the java solution i believe)?

    file_sep <- function(){
    ifelse(.Platform$OS.type == "unix", "/", "//")
    }
    file_sep()
    

    you can pick a shorter name if you like. The big flaw here is that you have to paste together file paths, but it's still worth it long term if you're working on big projects.

提交回复
热议问题