title: R - return multiple objects to a different (parent) environment
body: <p>I am writing a function where I will return several object.
  The usual way is to store them as a list and return the list.
  However, that means I will have to unlist the list to access those objects.</p>
  
  <p>Is there a way to instead store them in a different environment outside the function itself?</p>
  
  <p>I am thinking I will use this function directly inside my code or inside other function.
  The idea would be to push those object to the direct parent environment, so a function if I execute this function inside another function, or the global environment if I executed the function inline in my code.</p>
  
  <p>Best,</p>
  
  <hr>
  
  <p>Edit:
  Hi, I added a dummy list. It is actually data that I am using. The first element contains the dataset after modification by a function and a vector containing names of column that were added, that I use further in my code.
  Why I asked the question in the first place is that I want to extract the dataset and vector, and that they replace the original dataset or vector if they already exist, or create them if they don't.</p>
  
  <p>I will most likely call this inside a function that will use them further. I would normally do this with a loop but I'd rather a function to do this that I can call anytime.</p>
  
  <p>How would you do this?
  I tried with unlist but never achieved what I am after.</p>
  
  <hr>
  
  <pre><code>list(dummy2 = structure(list(interaction = c("Rutilus rutilus&lt;-Hydrachnidia", 
  "Rutilus rutilus&lt;-Hydrachnidia", "Rutilus rutilus&lt;-Hydrachnidia", 
  "Rutilus rutilus&lt;-Hydrachnidia", "Rutilus rutilus&lt;-Hydrachnidia", 
  "Rutilus rutilus&lt;-Hydrachnidia"), PREDATOR = c("Rutilus rutilus", 
  "Rutilus rutilus", "Rutilus rutilus", "Rutilus rutilus", "Rutilus rutilus", 
  "Rutilus rutilus"), PREY = c("Hydrachnidia", "Hydrachnidia", 
  "Hydrachnidia", "Hydrachnidia", "Hydrachnidia", "Hydrachnidia"
  ), interaction_type = c("eats", "eats", "preysOn", "preysOn", 
  "preysOn", "eats"), source = c("Globi", "Globi", "Globi", "Globi", 
  "Globi", "Globi"), pred_prey_lifestage = c("NA&lt;-NA", "larvae&lt;-larvae", 
  "larvae&lt;-larvae", "larvae&lt;-NA", "NA&lt;-NA", "NA&lt;-NA"), interaction_lifestage = c("NA&lt;-NA", 
  "larvae&lt;-larvae", "larvae&lt;-larvae", "larvae&lt;-NA", "NA&lt;-NA", "NA&lt;-NA"
  ), pred_lifestage = c(NA, "larvae", "larvae", "larvae", NA, NA
  ), prey_lifestage = c(NA, "larvae", "larvae", NA, NA, NA), lat = c(NA_character_, 
  NA_character_, NA_character_, NA_character_, NA_character_, NA_character_
  ), lon = c(NA_character_, NA_character_, NA_character_, NA_character_, 
  NA_character_, NA_character_), ref = c("Rowan Dunn, D. (1954). The Feeding Habits of some of the Fishes and some Members of the Bottom Fauna of Llyn Tegid (Bala Lake), Merionethshire. Journal of Animal Ecology, 23(2), 224�233.", 
  "Northcott, D. S., The role of aquatic macrophytes in the availabillty of food for young fish, 1981, PhD thesis, City of London Polytechnic, UK", 
  "Northcott, D. S., The role of aquatic macrophytes in the availabillty of food for young fish, 1981, PhD thesis, City of London Polytechnic, UK", 
  "Northcott, D. S., The role of aquatic macrophytes in the availabillty of food for young fish, 1981, PhD thesis, City of London Polytechnic, UK", 
  "Northcott, D. S., The role of aquatic macrophytes in the availabillty of food for young fish, 1981, PhD thesis, City of London Polytechnic, UK", 
  "Northcott, D. S., The role of aquatic macrophytes in the availabillty of food for young fish, 1981, PhD thesis, City of London Polytechnic, UK"
  ), data_provider = c("Gray C, Ma A, Perkins D, Hudson L, Figueroa D, Woodward G (2015). Database of trophic interactions. Zenodo. https://doi.org/10.5281/zenodo.13751. Accessed at &lt;https://github.com/globalbioticinteractions/gray2015/archive/95bfd96cc46e5d58482fd2bdad0677eeb74ba0f4.zip&gt; on 16 Feb 2020.", 
  "Gray C, Ma A, Perkins D, Hudson L, Figueroa D, Woodward G (2015). Database of trophic interactions. Zenodo. https://doi.org/10.5281/zenodo.13751. Accessed at &lt;https://github.com/globalbioticinteractions/gray2015/archive/95bfd96cc46e5d58482fd2bdad0677eeb74ba0f4.zip&gt; on 16 Feb 2020.", 
  "Gray C, Ma A, Perkins D, Hudson L, Figueroa D, Woodward G (2015). Database of trophic interactions. Zenodo. https://doi.org/10.5281/zenodo.13751. Accessed at &lt;https://github.com/globalbioticinteractions/gray2015/archive/95bfd96cc46e5d58482fd2bdad0677eeb74ba0f4.zip&gt; on 16 Feb 2020.", 
  "Gray C, Ma A, Perkins D, Hudson L, Figueroa D, Woodward G (2015). Database of trophic interactions. Zenodo. https://doi.org/10.5281/zenodo.13751. Accessed at &lt;https://github.com/globalbioticinteractions/gray2015/archive/95bfd96cc46e5d58482fd2bdad0677eeb74ba0f4.zip&gt; on 16 Feb 2020.", 
  "Gray, C., Ma, A., Perkins, D., Hudson, L., Figueroa, D., &amp; Woodward, G. (2015). Database of trophic interactions [Data set]. Zenodo. http://doi.org/10.5281/zenodo.13751. Accessed at &lt;https://zenodo.org/record/13751/files/trophic.links.2014-11-10.csv&gt; on 16 Feb 2020.", 
  "Gray, C., Ma, A., Perkins, D., Hudson, L., Figueroa, D., &amp; Woodward, G. (2015). Database of trophic interactions [Data set]. Zenodo. http://doi.org/10.5281/zenodo.13751. Accessed at &lt;https://zenodo.org/record/13751/files/trophic.links.2014-11-10.csv&gt; on 16 Feb 2020."
  )), row.names = c(351L, 361L, 362L, 366L, 376L, 377L), class = "data.frame"), 
      dummy2.addi = c("interaction", "interaction_lifestage"))
  </code></pre>