0

I am running Windows 10 64bit Pro.

I tried to run

path.expand("~")

in RStudio and it gave me

[1] "C:/Users/my_username/Documents"

However I tried to use Julia's RCall.jl

using RCall
R"path.expand('~')"

but it gave me

[1] "C:/Users/my_username/"

And they are both use the same R binaries. I wonder how is the folder "~" defined in R under Windows?

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
xiaodai
  • 14,889
  • 18
  • 76
  • 140
  • The result in RStudio looks much more suspicious (retry with R terminal session?). Since the same code is being run for both calls, it is strange to get different results. – Dan Getz Oct 21 '17 at 10:40
  • i did try. its the same as rstudio. – xiaodai Oct 21 '17 at 11:20
  • And what does Julia's `expanduser("~")` give? – Dan Getz Oct 21 '17 at 11:54
  • "RStudio" is just "R". The IDE doesn't usurp that particular function like it does a few others. Is it possible your Windows julia installation picked up a different (and weirdly compiled) R when it precompiled the RCall module? Do you get the same conflicting results after running the path expand call after doing `Base.compilecache("RCall")`? – hrbrmstr Oct 21 '17 at 12:04
  • See also https://stackoverflow.com/questions/11460556/how-to-reset-path-expand-on-tilde – Dan Getz Oct 21 '17 at 12:27

1 Answers1

1

It is defined in the environment variable HOME:

> path.expand("~")
[1] "U:/Data"
> Sys.getenv("HOME")
[1] "U:/Data"
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225
  • how is HOME defined and why is it different for different programs – xiaodai Oct 23 '17 at 20:58
  • 1
    @xiaodai You can change an environment variable for the current session with `Sys.setenv`, and you can change it definitely in the `Renviron` file. – Stéphane Laurent Oct 24 '17 at 09:44
  • 1
    I actually just solve it by doing .libPath(new_path). It's actually a bug in JuliaI https://github.com/JuliaInterop/RCall.jl/issues/206#issuecomment-338799926 – xiaodai Oct 25 '17 at 02:45