Re: [R] Create Matrix from Loop of Vectors, Sort It and Pick Top-K

2008-06-19 Thread Marc Schwartz
on 06/19/2008 09:59 AM Gundala Viswanath wrote: Hi, I have the following dataset (simplified for example). __DATA__ 300.35 200.25 104.30 22.00 31.12 89.99 444.50 22.10 43.00 22.10 200.55 66.77 Now from that I wish to do the following: 1. Compute variance of each row 2. Pick top-2 row with hi

Re: [R] Create Matrix from Loop of Vectors, Sort It and Pick Top-K

2008-06-19 Thread Jorge Ivan Velez
Dear Gundala, Try this: # Data set DF=read.table(textConnection("300.35 200.25 104.30 22.00 31.12 89.99 444.50 22.10 43.00 22.10 200.55 66.77"),header=FALSE,sep="") # Variances VAR=apply(DF,1,var) # Order pos=order(VAR) # Print VAR and pos VAR pos # ordered VAR VAR[pos] # top-2 highest VAR

[R] Create Matrix from Loop of Vectors, Sort It and Pick Top-K

2008-06-19 Thread Gundala Viswanath
Hi, I have the following dataset (simplified for example). __DATA__ 300.35 200.25 104.30 22.00 31.12 89.99 444.50 22.10 43.00 22.10 200.55 66.77 Now from that I wish to do the following: 1. Compute variance of each row 2. Pick top-2 row with highest variance 3. Store those selected rows for fu