Added support for matrices have NA value. Methods include: euclidean, maximum, manhattan, Canberra, and Minkowski.
Revised the computational formula of Canberra a little, based on dist source code.
Why?
These changes support the calculation of matrices with NA value, since original dist() supports.
The original computational formula of Canberra in parDist() gives different results than dist() when there is more than one NA value in one row. The changes in the computational formula of Canberra correct the results.
How?
Added function proportion() to normalize the results, and function remove_nan() to remove the NA values in matrices.
Revised the calDistance(). The revised calDistance() first removes the NA values in a calculated vector (e.g., A - B) using remove_nan(). Then come up with an intermediate result. Finally, normalize the result and get the final result using proportion().
Testing?
The code has passed the original test cases. I also add a new unit test file (testMatrixNA.R) to test the cases when matrices have NA values.
What?
Why?
How?
Testing?
The code has passed the original test cases. I also add a new unit test file (testMatrixNA.R) to test the cases when matrices have NA values.