Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205466

how to change a column with both negative and positive value into two columns with negative value plus zero and positive value plus zero

$
0
0

My data is the following:

t  B
1  2
2 -3
3 -7  

How could i have the output like below? It means that when the data from column B is negative, the column N will equal this columnB's data,or it will equal to zero. On the contrary, when the data from column B is positive, the column P will equal this data, or it will equal to zero.

t   B  N  P
1   2  0  2
2  -3 -3  0
3  -7 -7  0

Viewing all articles
Browse latest Browse all 205466

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>