 <p>I think you are trying to assign the various objects to the top level environment. Functions have their own environments, so assignments there exist only during the evaluation of the functions (which is why you can see the objects when <code>debug</code>ging). As soon as you your function returns, the objects in the body of the function cease to exist.</p> <p>In order to work around that, you can use <code>&lt;&lt;-</code> (i.e. <code>Butterfly_data &lt;&lt;- read.csv(...)</code>), as well as anytime you modify those objects within the function.</p> <p>Please keep in mind that <code>&lt;&lt;-</code> use is generally discouraged, and there is almost always a better way to do something than using <code>&lt;&lt;-</code>.</p> <p>For example, in this case, you could have returned a list with all your objects, and written a separate function that runs through the lists and produces the heads:</p> <pre><code>Extremes &lt;- function(siteno) { # bunch of stuff return(list(Precip=Precip, Tmax=Tmax, Tmin=Tmin)) } data.list &lt;- Extremes("mysiteno") lapply(data.list, head) # view the heads list2env(data.list) # if you really want objects available at top level directly </code></pre>