title: Importing xlsx data to R when numbers have a comma as decimal separator
body: <h3>How can I import data from a <code>.xlsx</code> file into R so that numbers are represented as numbers, when their original decimal separator is comma not a dot?</h3>
  
  <p>The only package I know of, when dealing with excel is <code>readxl</code> from <code>tidyverse</code>. </p>
  
  <p>I'm looking for a solution that won't need opening and editing excel files in any other software (and can deal with hundreds of columns to import) - if that would be possible I'd export all excels to <code>.csv</code> and import them using tools I know of, that can take the <code>dec=</code> argument.</p>
  
  <p>So far my best working solution is to import numbers as characters and then transform it:</p>
  
  <pre><code>library(dplyr)
  library(stringr)
  
  var1&lt;- c("2,1", "3,2", "4,5")
  var2&lt;- c("1,2", "3,33", "5,55")
  var3&lt;- c("3,44", "2,2", "8,88")
  df&lt;- data.frame(cbind(var1, var2, var3))
  
  df %&gt;%
        mutate_at(vars(contains("var")),
                  str_replace,
                  pattern = ",",
                  replacement = "\\.") %&gt;%
        mutate_at(vars(contains("var")), funs(as.numeric))
  </code></pre>