0

On my R 3.6.1 on Windows 10, the path "~" is assigned to oneDrive. I want to change but I can't find out how R determines the paths to "~". E.g

dir("~", full.names = T) list all files in the "~" directory and gives the directory.

xiaodai
  • 14,889
  • 18
  • 76
  • 140

1 Answers1

2

The shortcut ~ is a generic notion for "home" which on Unix resolves to the value of the environment variable $HOME -- which is not set by default on Windows.

> Sys.glob("~")   # Sys.glob() expands wildcards
[1] "/home/edd"
R> Sys.getenv("HOME")
[1] "/home/edd"
R> 

So the answer to your question, really, is 'how to I set the the environment variable $HOME on Windows. Which depends a little on your Windows version, but is generally available in the administrative tools. Here is one answer from SuperUser.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725