title: Use df name as file name when exporting in R
body: <p>I've created a function that helps me with extracting processed datasets to XLS saving them in a defined path and with a specified format always. However, I'd like to automate completely the name of the file by using, by default, the name of the df. What I have so far is the below function:</p>
  
  <pre><code>ExportFile &lt;- function(y) {
    write_xlsx(
      y,
      str_replace_all(paste("C:/MyPath/",
                            format(today(),"%Y%m%d"),
                            "_",
                            MyDataFrame,
                            ".xlsx"),
                      pattern=" ", repl="")
    )
  }
  </code></pre>
  
  <p>The idea is that the "MyDataFrame" text can be the same that I use for the expression (<code>ExportFile(MyDataFrame)</code>).</p>
  
  <p>As an extra point, would be amazing if someone can tell me how to do the below:</p>
  
  <ul>
  <li>If I write <code>ExportFile(MyDataFrame)</code> it will create a file called
  <em>20191002_MyDataFrame.xlsx</em>.</li>
  <li>But if I write <code>ExportFile(MyDataFrame,test)</code> it will create a file called
  <em>20191002_test.xlsx</em>.</li>
  </ul>
  
  <p>Anyone has the solution for, at least, the 1st one?</p>
  
  <p>Thank you!</p>