title: Why R's ifelse statements Return Error in write.csv()?
body: <p>I want to save CSV file with ifelse function</p>
  
  <pre><code>my_data&lt;-data.frame(fruits = c("orange","banana"),prices=c(2,3))
  
  ifelse(5&gt;3,write.csv(my_data,"mydata.csv",row.names = F),1+1)
  </code></pre>
  
  <p>I am getting this error in R console:</p>
  
  <pre><code>Error in ans[test &amp; ok] &lt;- rep(yes, length.out = length(ans))[test &amp; ok] : 
  </code></pre>
  
  <p>Anyone can help?</p>