本文介绍了设置工作目录:Julia 与 R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

R中,从任何工作目录开始,我都可以做到

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

setwd("~/Desktop")

这与我的 linux 发行版在命令行解释 cd 的方式一致.但是 Julia 似乎无法识别 ~/ 符号:

and this is consistent with how my linux distribution interprets cd at the command line. But Julia does not seem to recognize the ~/ notation:

julia> cd("~/Desktop")
ERROR: chdir ~/Desktop: No such file or directory
 in systemerror at error.jl:38
 in cd at file.jl:13

这是一个错误吗?

推荐答案

习语不同,如你所见 来自源头.如果不带参数调用 cd(),则默认为主目录.函数 homedir() 可用于添加主目录.

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"

组合事物

julia> cd("$(homedir())/Desktop")

julia> pwd()
"/Users/jeffw/Desktop"

这篇关于设置工作目录:Julia 与 R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 22:34