Setting working directory: Julia versus R

前端 未结 2 1651
说谎
说谎 2020-12-16 12:02

In R, starting from any working directory, I can do

setwd(\"~/Desktop\")

and this is consistent with how my linux distribution

相关标签:
2条回答
  • 2020-12-16 12:28

    The problem is that Julia doesn't expand the ~. You need to manually provide the full path. This is being worked on, but I'm on my phone right now and can't find issue.

    0 讨论(0)
  • 2020-12-16 12:46

    The idiom is just different as you can see from the source. If you invoke cd() without arguments, it defaults to the home directory. The function homedir() can be used to prepend the home directory.

    julia> homedir()
    "/Users/jeffw"
    
    julia> cd("/")
    
    julia> pwd()
    "/"
    
    julia> cd()
    
    julia> pwd()
    "/Users/jeffw"
    

    Combining things

    julia> cd("$(homedir())/Desktop")
    
    julia> pwd()
    "/Users/jeffw/Desktop"
    
    0 讨论(0)
提交回复
热议问题