'Swap specific values in matrix

A matrix has values ranging from 1-5, and dim = [1] 3219 10. What code will be best to swap 3 with 5 and 5 with 3 ?

The dataset has been converted to matrix using

[adhd <- as.matrix(original_dataset,replace=TRUE)]
r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source