[R] Filter Dataframe for Alarm for each column.

R_Antony antony.akkara at ge.com
Fri Jul 5 17:38:12 CEST 2013


Hi here i have a dataframe called MyDF.

a<-c(1,1,1,1,1,0,0,0,1,1)
b<-c(1,1,0,1,1,0,0,0,1,1)
c<-c(1,1,1,1,1,1,1,0,1,1)
d<-c(1,1,1,1,1,1,1,1,0,1)
MyDF<-data.frame(DWATT=a,TNH=b,CSGV=c,BIX=d)

My requirement is, here i need a function - to get for a particular row
number(s), when particular column(s) value change from zero to one  (for the
first change).

For example,  Using MyDF,

DWATT TNH CSGV BIX
1   1    1   1
1   1    1   1
1   0    1   1
1   1    1   1
1   1    1   1
0   0    1   1
0   0    1   1
0   0    0   1
1   1    1   0
1   1    1   1

Here i want to know, the row number where TNH-column and BIX-column values
change happening from one-to-zero for the first time.

Answer should be  a dataframe with single row.
So here answer should return a dataframe like this.

TNH  BIX
----    ------
3      9


i used some ways to get a solution using loops. But there is a bulk files
with bulk rows to process.
So performace is most important. Could someone please suggest better ideas ?

Thanks,
Antony.





--
View this message in context: http://r.789695.n4.nabble.com/Filter-Dataframe-for-Alarm-for-each-column-tp4670950.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list