Rectangle 27 0

Setting min and max values for matrix cells when running a for loop in r?


M[which(M<min)] = min
M[which(M>max)] = max
for (i in 1:50){
    M[which(M>min)] <- M[which(M>min)]-0.01
}

Run your loops through and get your results (outside of the range), then force the data to be within your min/max values with:

for the addition case and

Note
Rectangle 27 0

Setting min and max values for matrix cells when running a for loop in r?


M[which(M<min)] = min
M[which(M>max)] = max
for (i in 1:50){
    M[which(M>min)] <- M[which(M>min)]-0.01
}

Run your loops through and get your results (outside of the range), then force the data to be within your min/max values with:

for the addition case and

Note