Skip to content
Prev 201342 / 398502 Next

Re moving rows which do not satisfy a condition

Hello,

Considering 5 points in X-Y plain. Data is a 5*2 matrix (5 rows for samples
& 2 columns for X and Y)
With a distance from the origin, if a distance < 7, remove the row from the
Data.

After calculating the distance for each point, I can't forward because of
this "Removing" problem.

Anyone can help me?


Data=matrix(1:10,5,2) 

a=rep(0,5);
b=rep(0,5);
  
for (i in 1:5))
  {
     for (k in 1:2)
     {	
        a[i,k]=a[i,k]+(Data[i,k])^2
     }  
     b[i,j]=(a[i,j])^0.5   # distance from the origin
  }	
  

Thank you,

Jin