[R] Re moving rows which do not satisfy a condition

sandsky realstone at hotmail.com
Mon Nov 23 20:57:39 CET 2009


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
	


-- 
View this message in context: http://old.nabble.com/Removing-rows-which-do-not-satisfy-a-condition-tp26484778p26484778.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list