[R] Track Starting Row number for Continuos Increment

arun smartpink111 at yahoo.com
Fri Aug 23 09:07:03 CEST 2013


HI,

May be this works:
 row.names(MyDF)[c(0,diff(MyDF[,3]))==0|c(0,diff(MyDF[,3]))>1]
#[1] "1" "5" "8"
A.K.


Hi, 

Here i have a dataframe called MyDF. 

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

Requirement is, need to get the "starting row numbers" for a particular coulmn when the value increses continuosly. 
For Eg:- In this case, i need to get from the third column called 'CSGV'. 
So, Output should be - Row no:'s - 1,5,8. 

- Thanks 
ANTONY. 




More information about the R-help mailing list