title: How can I load an object into a variable name that I specify from an R data file?
body: <p>When you save a variable in an R data file using <code>save</code>, it is saved under whatever name it had in the session that saved it. When I later go to load it from another session, it is loaded with the same name, which the loading script cannot possibly know. This name could overwrite an existing variable of the same name in the loading session. Is there a way to safely load an object from a data file into a specified variable name without risk of clobbering existing variables?</p>
  
  <h2>Example:</h2>
  
  <h3>Saving session:</h3>
  
  <pre><code>x = 5
  save(x, file="x.Rda")
  </code></pre>
  
  <h3>Loading session:</h3>
  
  <pre><code>x = 7
  load("x.Rda")
  print(x) # This will print 5. Oops.
  </code></pre>
  
  <h3>How I want it to work:</h3>
  
  <pre><code>x = 7
  y = load_object_from_file("x.Rda")
  print(x) # should print 7
  print(y) # should print 5
  </code></pre>