Binding values from function to global environment in R
<p>I'm having trouble understanding how to bind values from within a function to an environment outside of the function. A basic example is shown below, I cannot seem to solve the last part of the function:</p>

<pre><code>number &lt;- data.frame()

how_many_fruits &lt;- function() {

    answer &lt;- as.integer(readline(prompt="How Many?: "))
    globalenv()$number &lt;- rbind(globalenv()$number, answer)

}
</code></pre>

<p>Essentially, I want to have an empty data frame called <code>number</code> in the beginning, and every time <code>how_many_fruits()</code> is run, I want the input to be attached to the bottom of the <code>number</code> data frame.</p>