[R] Excluding fixed number of rows from calculation while summarizing using ddply() function.

siddu479 onlyfordigitalstuff at gmail.com
Mon Nov 5 04:36:22 CET 2012


Hi Arun,

   Thanks for your reply but your script is removing only one row( first row
and last row) for each Unique and StepNo combination and calculating mean
for the rest of rows.
For below data , your script removing the #'s rows perfectly.
But in reality I may need to ignore *say first 10 rows and last 20 rows for
each Unique and StepNo combination.
* for statistics calculation.
 Unique StepNo Data1 Data2
1      A      1     4     5      #Your script removing this row
successfully.
2      A      1     5     6
3      A      1     7     8    
4      A      1     3     4      
5      A      1     1     1      #Your script removing this row
successfully.
6      B      1     2     4      #Your script removing this row
successfully.
7      B      1     3     5   
8      B      1     4     5
9      B      1     5     6
10    B      1     6     7      #Your script removing this row successfully.

Can you modify your script to get my requirement like below (making it
generic, here *N=2*, removing first 2 lines and last 2 lines.. *sometimes I
may have two numbers N1 & N2 (no.of rows need to be removed from and top and
bottom respectively*)

 Unique StepNo Data1 Data2
1      A      1     4     5      #Ignore this
2      A      1     5     6      #Ignore this
3      A      1     7     8    
4      A      1     3     4      #Ignore this
5      A      1     1     1      #Ignore this
6      B      1     2     4      #Ignore this
7      B      1     3     5      #Ignore this
8      B      1     4     5
9      B      1     5     6     #Ignore this
10    B      1     6     7     #Ignore this

and then calculate the statistics using ddply.

I hope my problem statement is much clear now.







-----
Sidda
Business Analyst Lead
Applied Materials Inc.

--
View this message in context: http://r.789695.n4.nabble.com/Excluding-fixed-number-of-rows-from-calculation-while-summarizing-using-ddply-function-tp4648406p4648447.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list