Setting working directory: Julia versus R

前端 未结 2 1658
说谎
说谎 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: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"
    

提交回复
热议问题