How can I loop through a dataframe and check for Inf and NA values in each cell. If there is an Inf or NA value in the cell then change it to a value of 0.
Here is an example dataframe
testdf <- data.frame(b1 = c(1,Inf,5,7,8,9,200,736, Inf, Inf),
b2 = c(2,3,Inf, NA,4,78,23,567,9114,94),
b3 = c(23,45,86,1236,78,Inf,324,2100,49,10))
> testdf
b1 b2 b3
1 1 2 23
2 Inf 3 45
3 5 Inf 86
4 7 NA 1236
5 8 4 78
6 9 78 Inf
7 200 23 324
8 736 567 2100
9 Inf 9114 49
10 Inf 94 10