I am new to R and I am working on function to manipulate a set of data.
I have a 20 by 5 matrix of values, to that I add a random number between -1 to 1. How can I ensure that all the values in the matrix stay between 0-10 in an efficient and fast manner (without using a loop to check a single value at a time).
These are the rules:
- If a value is greater than 10, change it to 10
- If a value is less thatn 0, change it to 0
Any help is appreciated. Thanks!