all.equal() gives an "invalid argument type" error with these data. Any idea?
>matrix1
1 2 3 4 5
1 0 0 0.0 0 0.0
2 1 0 0.0 0 0.0
3 0 1 0.0 0 0.0
4 0 0 0.5 0 0.5
5 0 0 1.0 0 0.0
>rowSums(matrix1)
1 2 3 4 5
0 1 1 1 1
> !all.equal(as.vector(rowSums(matrix1)), as.vector(rep(1, nrow(matrix1))), check.attributes=FALSE)
Error in !all.equal(as.vector(rowSums(matrix1)), as.vector(rep(1, :
invalid argument type
all.equal is not returning that error, ! is:
> !""
Error in !"" : invalid argument type
This is because all.equal does not return a logical value when the two objects aren't roughly equal. This is documented in the first paragraph of ?all.equal, where it suggests you use isTRUE(all.equal(...)).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With