EVOLUTION-MANAGER
Edit File: path_expand.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Finding the User Home Directory</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for path_expand {fs}"><tr><td>path_expand {fs}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Finding the User Home Directory</h2> <h3>Description</h3> <ul> <li> <p><code>path_expand()</code> performs tilde expansion on a path, replacing instances of <code>~</code> or <code>~user</code> with the user's home directory. </p> </li> <li> <p><code>path_home()</code> constructs a path within the expanded users home directory, calling it with <em>no</em> arguments can be useful to verify what fs considers the home directory. </p> </li> <li> <p><code>path_expand_r()</code> and <code>path_home_r()</code> are equivalents which always use R's definition of the home directory. </p> </li></ul> <h3>Usage</h3> <pre> path_expand(path) path_expand_r(path) path_home(...) path_home_r(...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>path</code></td> <td> <p>A character vector of one or more paths.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Additional paths appended to the home directory by <code><a href="path.html">path()</a></code>.</p> </td></tr> </table> <h3>Details</h3> <p><code>path_expand()</code> differs from <code><a href="../../base/html/path.expand.html">base::path.expand()</a></code> in the interpretation of the home directory of Windows. In particular <code>path_expand()</code> uses the path set in the <code>USERPROFILE</code> environment variable and, if unset, then uses <code>HOMEDRIVE</code>/<code>HOMEPATH</code>. </p> <p>In contrast <code><a href="../../base/html/path.expand.html">base::path.expand()</a></code> first checks for <code>R_USER</code> then <code>HOME</code>, which in the default configuration of R on Windows are both set to the user's document directory, e.g. <code style="white-space: pre;">C:\\Users\\username\\Documents</code>. <code><a href="../../base/html/path.expand.html">base::path.expand()</a></code> also does not support <code>~otheruser</code> syntax on Windows, whereas <code>path_expand()</code> does support this syntax on all systems. </p> <p>This definition makes fs more consistent with the definition of home directory used on Windows in other languages, such as <a href="https://docs.python.org/3/library/os.path.html#os.path.expanduser">python</a> and <a href="https://doc.rust-lang.org/std/env/fn.home_dir.html#windows">rust</a>. This is also more compatible with external tools such as git and ssh, both of which put user-level files in <code>USERPROFILE</code> by default. It also allows you to write portable paths, such as <code style="white-space: pre;">~/Desktop</code> that points to the Desktop location on Windows, macOS and (most) Linux systems. </p> <p>Users can set the <code>R_FS_HOME</code> environment variable to override the definitions on any platform. </p> <h3>See Also</h3> <p><a href="https://cran.r-project.org/bin/windows/base/rw-FAQ.html#What-are-HOME-and-working-directories_003f">R for Windows FAQ - 2.14</a> for behavior of <code><a href="../../base/html/path.expand.html">base::path.expand()</a></code>. </p> <h3>Examples</h3> <pre> # Expand a path path_expand("~/bin") # You can use `path_home()` without arguments to see what is being used as # the home diretory. path_home() path_home("R") # This will likely differ from the above on Windows path_home_r() </pre> <hr /><div style="text-align: center;">[Package <em>fs</em> version 1.5.2 <a href="00Index.html">Index</a>]</div> </body></html>