title: Why do my function returns a dataframe but it cannot attribute the dataframe to a variable in r?
body: <p>I'm having a hard time here on writting a simple function which creates a unique code for forest productive areas, using 3 columns of the dataframe. <br>
  Apparently, the function is running fine, but when I try to attribute the result which is returned (which is a dataframe) to a variable, like <code>result &lt;- cod_uni(dataframe)</code>, it doesn't work, the console executes the line normally, but the variable isn't even created in Global Environment.<br>
  When I run the function whithout attributing the result to a variable it shows the dataframe with the new column with unique codes (as I was expecting).
  Here is the function:<br></p>
  <pre><code>cod_uni &lt;- function(x, tipo = 'talhao') {
    i &lt;- sapply(x, is.factor)
    x[, i] &lt;- as.character(x[, i])
    
    if (tipo == 'talhao'){
      x$CONCAT_T &lt;- paste(x$ESTADO_FEDERATIVO, 
                     x$CD_HORTO, 
                     x$CD_TALHAO, sep = '_')
    } else if (tipo == 'horto') {
      x$CONCAT_H &lt;- paste(x$ESTADO_FEDERATIVO,
                       x$CD_HORTO,
                       sep = '_')
    } else {
      return(stop('Tipo de código único inválido, escolher entre &quot;horto&quot; ou &quot;talhao&quot;'))
    }
    print(class(x)) #I've put this print to be sure of the variable class - it's returning &quot;data.frame&quot;
    return(x)
  }
  </code></pre>
  <p>OBS: It doesn't return any error but I've already debbuged the function anyway.</p>