title: R: write.xlsx2 file name as Sys.time()
body: <p>I am trying to output my data frame in R to Excel file with write.xlsx2 function. </p>
  
  <p>I would like to set the file name as today's data though. </p>
  
  <p>I tried codes below:</p>
  
  <pre><code>paste(c(format(Sys.time(), "%m%d%Y"), '.xlsx'), sep="")
  </code></pre>
  
  <p>And the result was</p>
  
  <pre><code>[1] "03202017" ".xlsx"
  </code></pre>
  
  <p>Okay. I gotta get rid of that quotation marks. </p>
  
  <pre><code>noquote(paste0(c(format(Sys.time(), "%m%d%Y"),'.xlsx'), sep =""))
  </code></pre>
  
  <p>It seems to work but the result has that annoying space in between as below:</p>
  
  <pre><code>[1] 03202017 .xlsx
  </code></pre>
  
  <p>The worst part was it DOES NOT work in write.xlsx2 function:</p>
  
  <pre><code>write.xlsx2(fcst,noquote(paste0(c(format(Sys.time(), "%m%d%Y"),'.xlsx'), sep ="")) , sheetName = "Sheet1", append=F)
  </code></pre>
  
  <p>Error Message as below:</p>
  
  <pre><code>Error in createWorkbook(type = ext) : 
    Unknown format 03202017Unknown format xlsx
  In addition: Warning messages:
  1: In if (type == "xls") { :
    the condition has length &gt; 1 and only the first element will be used
  2: In if (type == "xlsx") { :
    the condition has length &gt; 1 and only the first element will be used
  </code></pre>
  
  <p>What have I done wrong? How can I remove the space in between. </p>
  
  <p>How can I output an excel file with today's date in file name?</p>
  
  <p>Thank you.</p>