Change Path.Expand Location (Win 7)

Change path.expand location (Win 7)

To persistently reset the directory that "~" resolves to for all users, put the following in the file Renviron.site, located in $RHOME/etc/Renviron.site:

R_USER="C:/Users/trinker"

(If the file is not already there, you can just create it yourself.)


If a computer supports multiple R users, and each wants to set their own R_USER location, each can put the following in their own ".Rprofile" file:

Sys.setenv(R_USER = "C:/Users/trinker")

".Rprofile" is looked for in the user's home directory, which is returned by typing Sys.getenv("HOME"). See ?Startup and the R for Windows FAQ for more details.

(Thanks to @Dason for pointing out the .Rprofile option.)

How to reset path.expand on tilde

Define HOME="/my/projects/folder", preferably for R only, in .Renviron

Functionality for changing the method of ~ path expansion on windows does not exist in the same fashion as Windows as it does in Ubuntu/Linux*

setting the home directory in windows R

You can change this by adding an R_USER variable to your Rprofile.site file.

Sys.setenv(R_USER="/my/desired/path/to/tilde")

This does not work on linux systems. See a related question: How to reset path.expand on tilde

Adding a directory to the PATH environment variable in Windows

This only modifies the registry. An existing process won't use these values. A new process will do so if it is started after this change and doesn't inherit the old environment from its parent.

You didn't specify how you started the console session. The best way to ensure this is to exit the command shell and run it again. It should then inherit the updated PATH environment variable.

How to persistently set a variable in Windows 7 from a batch file?

Use setx.exe instead of set.

setx PATH "%cd%;%path%;"
pause

Note that this sets the path for all future cmd instances, but not for the current one. If you need that, also run your original set command.

UPDATE: The second parameter needs to be quoted if it contains spaces (which %path% always has). Be warned that if the last character in your %path% is a backslash, it will escape the trailing quote and the last path entry will stop working. I get around that by appending a semicolon before the closing quote.

If you don't want to risk getting ";;;;;;" at the end of your path after repeated runs, then instead strip any trailing backslash from the %path% variable before setting, and it will work correctly.

Changing default startup directory for command prompt in Windows 7

While adding a AutoRun entry to HKEY_CURRENT_USER\Software\Microsoft\Command Processor like Shinnok's answer is the way to go it can also really mess things up, you really should try to detect a simple cmd.exe startup vs a script/program using cmd.exe as a child process:

IF /I x"%COMSPEC%"==x%CMDCMDLINE% (cd /D c:\)

How to update system PATH variable permanently from cmd?

Type setx /? to get basic command help. You'll easily discover:

/M                     Specifies that the variable should be set in
the system wide (HKEY_LOCAL_MACHINE)
environment. The default is to set the
variable under the HKEY_CURRENT_USER
environment.

You need to run this from an elevated command prompt. Right-click the cmd shortcut and select Run as Administrator.

E.g.

setx /M PATH "%PATH%;C:\Something\bin"

Caution:

We may destroy the current system's PATH variable. Make sure you backup its value before you modify it.

How is the path ~ determined on Windows R?

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.



Related Topics



Leave a reply



Submit