Re: [R] merge by time, certain value if 5 min before and after an "event"

2014-10-04 Thread Dagmar
Thank you Jean, Petr, Terry, William and everyone else who thought about my problem. It is sooo good that this mailing list exists! I solved my problem using Petr's suggestion, that didn't seem so complicated and worked fine for me. Thanks again and have a great weekend, Dagmar Am 02.10.2014

Re: [R] merge by time, certain value if 5 min before and after an "event"

2014-10-03 Thread William Dunlap
Hi Terry, Some of that combination of sort() and approx() can be done by findInterval(), which may be quick enough that you don't need the 'thinning' part of the code. Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Oct 3, 2014 at 6:05 AM, Therneau, Terry M., Ph.D. wrote: > I've attached

[R] merge by time, certain value if 5 min before and after an "event"

2014-10-03 Thread Therneau, Terry M., Ph.D.
I've attached two functions used locally. (The attachments will be stripped off of the r-help response, but the questioner should get them). The functions "neardate" and "tmerge" were written to deal with a query that comes up very often in our medical statistics work, some variety of "get the

Re: [R] merge by time, certain value if 5 min before and after an "event"

2014-10-03 Thread PIKAL Petr
our mydata and use na.locf to fill gaps you should get desired result. Regards Petr > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Dagmar > Sent: Thursday, October 02, 2014 11:25 PM > Cc: R help > Subject: Re: [R]

Re: [R] merge by time, certain value if 5 min before and after an "event"

2014-10-03 Thread PIKAL Petr
e.g. by ?complete.cases Regards Petr > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Adams, Jean > Sent: Thursday, October 02, 2014 11:38 PM > To: Dagmar > Cc: R help > Subject: Re: [R] merge by time, certain va

Re: [R] merge by time, certain value if 5 min before and after an "event"

2014-10-02 Thread Adams, Jean
Thanks, Dagmar. So, shouldn't row 3 with a time of 09:51:01 be "low" and not "high"? Jean On Thu, Oct 2, 2014 at 4:25 PM, Dagmar wrote: > Dear Jean and all, > > I want all lines to be "low", but during times 9:55 - 10:05 a.m (i.e. a > timespan of 10 min) I want them to be "high". > In my real

Re: [R] merge by time, certain value if 5 min before and after an "event"

2014-10-02 Thread Dagmar
Dear Jean and all, I want all lines to be "low", but during times 9:55 - 10:05 a.m (i.e. a timespan of 10 min) I want them to be "high". In my real data "low" and "high" refer to "lowtide" and "hightide" in the waddensea and I want to assign the location of my animal at the time it was taken to

Re: [R] merge by time, certain value if 5 min before and after an "event"

2014-10-02 Thread Adams, Jean
Dagmar, Can you explain more fully why rows 1, 2, and 5 in your result are "low" and rows 3 and 4 are "high"? It is not clear to me from the information you have provided. > result[c(1, 2, 5), ] Timestamp location Event 1 24.09.2012 09:05:011 low 2 24.09.2012 09:49:50

[R] merge by time, certain value if 5 min before and after an "event"

2014-10-02 Thread Dagmar
Hello! I hope someone can help me. It would save me days of work. Thanks in advance! I have two dataframes which look like these: myframe <- data.frame (Timestamp=c("24.09.2012 09:00:00", "24.09.2012 10:00:00", "24.09.2012 11:00:00"), Event=c("low","high","low") ) myframe mydata <- data.frame