Re: [R] How do I identify non-sequential data?

2013-11-21 Thread Lopez, Dan
(c(0,diff(x))>1,] I appreciate your response on this. Dan -Original Message- From: MacQueen, Don Sent: Thursday, November 21, 2013 3:58 PM To: Lopez, Dan; R help (r-help@r-project.org) Subject: Re: [R] How do I identify non-sequential data? Dan, Does this do it? ## where dt is

Re: [R] How do I identify non-sequential data?

2013-11-21 Thread arun
Hi, You may try:  with(testSeq,ave(YoS,ID,FUN=function(x) c(0,diff(x # [1] 0.0 1.0 0.0 1.0 1.0 0.0 2.1 0.0 1.0 3.0 1.0  testSeq[!!(with(testSeq,ave(YoS,ID,FUN=function(x) any(c(0,diff(x))>1,] A.K. On Thursday, November 21, 2013 6:55 PM, "Lopez, Dan" wrote: Hi R Experts, About the da

Re: [R] How do I identify non-sequential data?

2013-11-21 Thread MacQueen, Don
Dan, Does this do it? ## where dt is the data tmp <- split(dt, dt$ID) foo <- lapply(tmp, function(x) any(diff(x$YoS) > 1)) foo <- data.frame( ID=names(foo), gap=unlist(foo)) Note that I ignored dept. Little hard to see how YoS can increase by more than one when the year increases by only one .

[R] How do I identify non-sequential data?

2013-11-21 Thread Lopez, Dan
Hi R Experts, About the data: My data consists of people (ID) with years of service (Yos) for each year. An ID can appear multiple times. The data is sorted by ID then by Year. Problem: I need to extract ID data with non-sequential YoS rows. For example below that would be all rows for ID 33 an