title: Unable to resolve a simple If-Else Function error in R
body: <p>I am just trying to gain some knowledge about how to write functions in R. I created a simple <code>If-else</code> function which basically takes numerical input in function call.</p>
  
  <p>If user gives <code>n=1</code>, iris dataframe is to be created and for any other number <code>mtcars</code>.</p>
  
  <pre><code>df1&lt;-iris
  df2&lt;-mtcars
  run&lt;-function(n){
    if(n==1){
     data1&lt;-df1
    } else {
      data1&lt;-df2
    }
  }
  
  run(1)
  </code></pre>
  
  <p>But somehow this is just not working. I am missing something here.</p>