I have a matrix of values and the sums of each row must equal 0 but at the moment they are close but not exactly zero (e.g. -3.12...e-15). I'd like to force the values in the rows to make a sum of 0.
EDIT:
I have a matrix where the diagonal must equal the negative sum of the row so that the rowSums() should be exactly 0.
For example:
A<-matrix(rexp(16, rate=.1), ncol=4)
diag(A)-rowSums(A)
[1] -12.071549 -14.267157 -7.328108 -25.077841
diag(A)<-diag(A)-rowSums(A) #To make diagonal = negative sum
So rowSums(A) should be exactly 0 but they're not:
> rowSums(A)
[1] 0.000000e+00 -1.776357e-15 -8.881784e-16 -1.776357e-15