title: How to add new values to a new column in a dataframe in R?
body: <p>I need to do some computations with the data stored in a dataframe. ANd put the result into new column of this dataframe.</p>
  
  <p>Initial dataframe:</p>
  
  <pre><code>    &gt; str(mydf)
      'data.frame':   1122 obs. of  6 variables:
       $ MMSI       : num  2.73e+08 2.73e+08 2.73e+08 2.73e+08 2.73e+08 ...
       $ MMSI.1     : num  2.73e+08 2.72e+08 2.72e+08 2.72e+08 6.67e+08 ...
       $ LATITUDE   : num  46.9 46.9 46.9 46.9 46.9 ...
       $ LONGITUDE  : num  32 32 32 32 32 ...
       $ LATITUDE.1 : num  46.9 46.9 46.9 46.9 46.9 ...
       $ LONGITUDE.1: num  32 32 32 32 32 ...
  </code></pre>
  
  <p>Now I need to add a new column which contain the result of operation with the data of the current raw..</p>
  
  <p>running next code:</p>
  
  <pre><code>    library(geosphere)
       &gt; mydf$distance &lt;- with(mydf, distGeo(c(mydf$LONGITUDE,mydf$LATITUDE),c(mydf$LONGITUDE,mydf$LATITUDE)))
      Error in .pointsToMatrix(p1) : Wrong length for a vector, should be 2
  </code></pre>
  
  <p>I understand that's the structure of the data for function distGeo should be different. 
  How to fix this error or how to change the code to get the distances between point in a new column?</p>