powered by
signp
signp(x)
sign
signp(-1:1) # -1 1 1 instead of sign(-1:1) = -1 0 1 (m <- matrix(rnorm(9),3,3)) m %*% diag(signp(diag(m)))
Run the code above in your browser using DataLab