Source script to separate environment in R, not the global environment
<p>Is there a way to <code>source()</code> a script in <strong>R</strong> such that it is attached as a parent to the global environment (<code>.GlobalEnv</code>)?</p>

<p>Currently, when I source a script, all variables and functions of that script appear in my global (interactive) environment. I'd like to include these variables and functions in the search path, but not in <code>.GlobalEnv</code>. That is, I'd like the sourced script to behave like an attached package, which gets attached between the global and base environments (see figure from <a href="http://adv-r.had.co.nz/Environments.html" rel="noreferrer"><strong><em>Advanced R</em></strong> <em>Environments</em></a>)</p>

<p><a href="https://i.stack.imgur.com/lPmIV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lPmIV.png" alt="enter image description here"></a></p>