title: Replacing commas and dots in R
body: <p>I have a whole column of numbers that include dot separators at the thousands and comma instead of dot as an dismal separator. When I try to create a numeric column out of them, I lose all data.</p>
  
  <pre><code>var1 &lt;- c("50,0", "72,0", "960,0", "1.920,0", "50,0", "50,0", "960,0")
  df &lt;- cbind(var1, var2 = as.numeric(gsub(".", "", as.character(var1))))
  </code></pre>
  
  <p>and wound up with:</p>
  
  <pre><code> var1      var2
  [1,] "50,0"    NA  
  [2,] "72,0"    NA  
  [3,] "960,0"   NA  
  [4,] "1.920,0" NA  
  [5,] "50,0"    NA  
  [6,] "50,0"    NA  
  [7,] "960,0"   NA 
  </code></pre>
  
  <p>What am I doing wrong?</p>