I have some R that is, for example:
x<-c(-3,1,-5,7,-10)
y<-c(1,2,3,4,5)
I want to check the elements of x against some condition, i.e. <0, and if true, manipulate y based on that.
For example, if my logical check was x<0, then elements [0],[2],[4] of y would be modified, i.e.:
print(y)
y=[0,2,0,3,0]
I've googled around a bit and cant find anything that does it element-wise. I'm sure that is a failing of google-fu, but help much appreciated.