title: Function: save returned data frame to workspace
body: <p>I cannot really get my head around this problem:</p>
  
  <p>I have a function that returns a data frame. However, the data frame is only printed in my console although I would like to have it stored in the work space. How can I achieve this? </p>
  
  <p>Sample data:</p>
  
  <pre><code>n &lt;- 32640
  t &lt;- seq(3*pi,n)
  data_sim &lt;- 30+ 2*sin(3*t)+rnorm(n)*10
  data_sim &lt;- floor(data_sim)
  </code></pre>
  
  <p>Function:</p>
  
  <pre><code>compress &lt;- function (name, SR){
    ## -------------------------------------------------------
    ## COMPRESSION
    library(zoo)
    data &lt;- get(name)
    if (is.data.frame(data)==F){
      data = as.data.frame(data)
    }
    SR &lt;- SR
    acrossmin &lt;- 60  
    a &lt;- nrow(data) 
    m &lt;- acrossmin*SR*60  
    data_compress &lt;- matrix(NA, nrow = a/m) 
    no_mov_subset &lt;- matrix(NA, nrow = m) 
    for (i in 1:(a/m)){
      subset &lt;- data[(((i-1)*m)+1):((i*m)),] 
      b &lt;- length(subset)
      for (k in 1:b){
        r &lt;- subset[k]
        if (r == 0){              
          no_mov_subset[k] &lt;- 0    
        } else {
          no_mov_subset[k] &lt;- 1
        }
        sum_no_mov_subset &lt;- sum(no_mov_subset) 
        data_compress[i] &lt;- sum_no_mov_subset  
      }
     colnames(data_compress) &lt;- c("activity_count")
  return(data_compress)
  }
  </code></pre>
  
  <p>Run the code:</p>
  
  <pre><code>compress("data_sim", 4/60)
  </code></pre>
  
  <p>Obviously, the function returns something, but I would like it to be stored in the workspace rather than returned!</p>