Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replace 0's with 1's and vice versa for a diagonal matrix in R

Tags:

r

Can anyone tell me how to replace 0's with 1's and vice versa for a diagonal matrix in R.

like image 332
Shruti Avatar asked Dec 07 '22 02:12

Shruti


1 Answers

If your matrix is mat and you want to flip all 1s as 0s...

mat <- 1-mat
like image 148
John Avatar answered Dec 09 '22 14:12

John