title: Automatically - "Convert numbers stored as text to numbers"
body: <p>Lets consider this small example:</p>
  
  <pre><code>df1&lt;- data.frame(A=c(1,NA,"pvalue",0.0003),B=c(0.5,7,"I destroy","numbers all day"),stringsAsFactors = T)
  </code></pre>
  
  <p>Write file:</p>
  
  <pre><code>openxlsx::write.xlsx(df1,"Test.xlsx")
  </code></pre>
  
  <p>In my resulting excel file, <code>1</code> and <code>7</code> are text cells. Excel has the "intuition" that they are numbers stored as text. I can convert them by hand.</p>
  
  <p>How can I convert those "flagged" values automatically to numbers from inside R?</p>
  
  <p>In the "What I want" I have by hand converted the TEXT into Numbers. It's an option behind the "green triangle" in the "What I get" Part (red arrows).</p>
  
  <p><a href="https://i.stack.imgur.com/CKgr9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CKgr9.png" alt="enter image description here"></a></p>
  
  <p>@Roland's comment: Rearranging as list does not work.</p>
  
  <pre><code>df1&lt;- as.data.frame(cbind(A=list(1,NA_real_,"pvalue",0.0003),B=list(0.5,7,"I destroy","numbers all day")))
  openxlsx::write.xlsx(df1,"Test2.xlsx")
  </code></pre>