I need to do a subtraction of two objects, but I don't get the expected result
library(matrixStats)
A<-matrix(c(5, 7, 4, 1, 14, 3), nrow=3, ncol=2, byrow=T,
dimnames=list(c("Blanco", "Negro", "Rojo"), c("Toyota", "Audi")))
> A
Toyota Audi
Blanco 5 7
Negro 4 1
Rojo 14 3
mx <- colMaxs(A)
> mx
[1] 14 7
A-mx
Toyota Audi
Blanco -9 0
Negro -3 -13
Rojo 0 -4
What I want is that the maximum number is subtracted with its corresponding column, like this:
Toyota Audi
Blanco -9 0
Negro -10 -6
Rojo 0 -4
The error in in the row "Negro". It's inverted.