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

Add (+) 1 to each row that has 0 in dataframe

$
0
0

I have a dataframe that looks like this.

df1 <- read.table(text = "    REF_CNT.x ALT_CNT.x REF_CNT.y ALT_CNT.y
1         397         0       574         2
2         417         2       219         0
3         537         2        31         0
4         117         5       154         0
5          76         2        52         0
6         238         0       102         2
7         265         0       108         2
8         177         6       156         6
9         407         0       359         4
10        770         3        64         0", header = TRUE)

How do I add 1 to each row if there is 0 in the row?


Viewing all articles
Browse latest Browse all 201977

Trending Articles



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