I have a vector 'participant' in R.
> participant [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 I am using a function 'modify' to change the contents of this vector.
modify <- function(x){ for (i in participant){ if (x[i] > 12) (x[i]=x[i]-12) print (x[i]) }} When I run the function as modify(participant), it runs OK, but the elements of the vector participant remain unchanged.
Any suggestion, for where am I going wrong ?
participant[participant > 12] <- participant[participant > 12] - 12