title: Assign multiple objects to .GlobalEnv from within a function
body: <p>A post on here a day back has me wondering how to assign values to  multiple objects in the global environment from within a function. This is my attempt using <code>lapply</code> (<code>assign</code> may be safer than <code>&lt;&lt;-</code> but I have never actually used it and am not familiar with it). </p>
  
  <pre><code>#fake data set
  df &lt;- data.frame(
    x.2=rnorm(25),
    y.2=rnorm(25),
    g=rep(factor(LETTERS[1:5]), 5)
  )
  
  #split it into a list of data frames
  LIST &lt;- split(df, df$g)
  
  #pre-allot 5 objects in R with class data.frame()
  V &lt;- W &lt;- X &lt;- Y &lt;- Z &lt;- data.frame()
  
  #attempt to assign the data frames in the LIST to the objects just created
  lapply(seq_along(LIST), function(x) c(V, W, X, Y, Z)[x] &lt;&lt;- LIST[[x]])
  </code></pre>
  
  <p>Please feel free to shorten any/all parts of my code to make this work (or work better/faster).</p>