Isso pode servir de inspiração.

http://stackoverflow.com/questions/9439619/using-r-replace-all-values-in-a-matrix-0-1-with-0

À disposição.
Walmes.