4

When I call Sys.getenv("HOME") is c:/users/paull/OneDrive/Documents

However, when I go into the command prompt I get

echo $USERPROFILE
C:/users/paull

(using cygwin)

simlarly using command prompt, I have

echo %USERPROFILE%
C:/users/paull

So it seems that R's user home is not actually my users home directory.

Anyone know where this strange behavior is coming from?

Paul
  • 1,106
  • 1
  • 16
  • 39
  • is this helpful? http://stackoverflow.com/questions/1494658/how-can-i-change-my-cygwin-home-folder-after-installation – Ben Bolker Mar 10 '17 at 01:22
  • 2
    What is `Sys.getenv("HOME")`? I had to set that manually within windows' Environment Variables dialog ... and setting it to `%USERPROFILE%` was sufficient for me. – r2evans Mar 10 '17 at 01:22
  • @r2evans, thank you. I tried a few similar things like `Sys.getenv("R_HOME")`, `Sys.getenv("~")`, but I didn't try that. Lo and behold the output of `> Sys.getenv("HOME")` is `"C:/Users/paull/OneDrive/Documents"` – Paul Mar 10 '17 at 22:20
  • Sooooo ... that resolves the problem? Working with R on Windows has several quirks like that ... including "space in path names", definition of `"HOME"`, multi-arch compilation of package C/C++ source ... several things that keep me on my toes when switching back/forth between one OS and another. – r2evans Mar 10 '17 at 22:23
  • sorry for being slow on this -- but how do I change that variable? I seem to remember being able to do this through the control panel for system environment variables, but I don't see anything set for HOME or %userprofile% has value `c:/users/paull`, the correct value. But I was under the impression that this is the same as my users HOME? – Paul Mar 10 '17 at 22:51
  • ok, it seems that the problem may be that my R_USER is the dropbox account. I have no idea how to why this happened, but I think I should be able to fix it. – Paul Mar 11 '17 at 20:10
  • Ok great, thanks. I set my home variable, and the problem was solved. I am still confused about why rather than following the flow that you described (check "HOME", see that it isn't set, and then default to "USERPROFILE"), it instead decided to set it to my dropbox folder without checking my userprofile? – Paul Mar 11 '17 at 20:27

1 Answers1

-1

I don't use R, but in other languages normally "~" doesn't refer to the working directory but the $HOME directory.

The working directory is assumed if you don't prepend anything.

So try: scan("wgaca/data_dir.txt")

And give this video a looksie: https://www.youtube.com/watch?v=fe6GA200dks

FredMan
  • 861
  • 7
  • 19
  • I think the OP knows that, although their question admittedly makes that a little unclear. – Ben Bolker Mar 10 '17 at 01:54
  • ok yes, but by default my working directory is set to my user home directory. I think what I really mean is that my `%userprofile%` is not the same as my home directory. – Paul Mar 11 '17 at 19:56