How to replace non-zero values as default in data.frame object by row-wise?
<p>I have data.frame object that consist of two vectors v1, v2. As you can see from my data, v1 contains 0e+00, I want to assign this values to the row that contains 0e+00. I attempted to do this but I did not get what I expected. How can do this in R? 
However, this is my attempt to do this, but it won't work:</p>

<pre><code>res&lt;- apply(data, 1, function(ro) {
  tmp&lt;- ifelse(length(ro[[1]]==0 &amp; !length(ro[[2]])==0),0e+00, ro)
})
</code></pre>

<h1>reproducible example as follow:</h1>

<pre><code>v1 &lt;- c( 1e-06,1e-05,0e+00,0e+00,0e+00,1e-07,0e+00)
v2 &lt;- c(4.551651e-38,3.519523e-33,6.316980e-26,8.159048e-34,
        4.935429e-20,4.551651e-38,9.080082e-38)

dat &lt;- data.frame(v1, v2)
</code></pre>

<h1>My desired output (I did manually here to show how it looks like):</h1>

<pre><code>DataFrame with 7 rows and 2 columns
         v1    v2
  &lt;numeric&gt;    &lt;numeric&gt;
1     1e-06 4.551651e-38
2     1e-05 3.519523e-33
3     0e+00 0e+00
4     0e+00 0e+00
5     0e+00 0e+00
6     1e-07 4.551651e-38
7     0e+00 0e+00
</code></pre>

<h1>then I want to cancel out that row contains 0e+00, so final desired output:</h1>

<pre><code>DataFrame with 7 rows and 2 columns
         v1    v2
  &lt;numeric&gt;    &lt;numeric&gt;
1     1e-06 4.551651e-38
2     1e-05 3.519523e-33
3     1e-07 4.551651e-38
</code></pre>

<p>How can I get my desired output?</p>