
  
  
     Dear R Users,
  
  Suppose we want to creat a new vector ( x ) from a current vector (y)  of length 1000. The current vector y includes negative, zero and  positive values. We want our new vector x includes the negative values  in y, otherwise NA with the same length as y.
  
  For this, we have  x=y[y<0]  . Now x includes a subset of  y with shorter length than y. With x=match(y,x) we would have  a  vector of indices equal to the length of y. x=y[x] gives us a vector of  values with the same length as y. But when I implement such a  procedure, x dose not merely include negative values. It includes  negative, NA and also positive values.
  What could be the reason for appearing pasitive values? And how to  correct this? And more generally how can this purpose be coded more  convenient?
  
  Thank you so much for any reply.
  
  Amir Safari

