title: How can i create a function that returns a vector in R?
body: <p>I want to create a function that returns its result as a vector, more specifically a function that returns the divisors of an input value and places them inside a vector.</p>
  
  <pre><code>divisors&lt;-function(n){
    i &lt;- 2
    c&lt;-1
  
      x&lt;-c()
  
        while(i &lt;= n) {
          if(n%%i==0) {
          x[c]&lt;-i  
  
          }
          i &lt;- i + 1
          c&lt;-c+1
          x
  
  
        }
  
      }
  </code></pre>