overlap

how to identify time overlap in r

纵饮孤独 提交于 2020-01-06 09:30:33
问题 I have a dataframe (df) with admission and discharge dates of patients, with 4 columns: ID, admitDate (as date), dcDate (as date), los (length of stay in days). $ admitDate : Date, format: "2009-09-19" "2010-01-24" "2010-09-30" ... $ dcDate : Date, format: "2009-09-23" "2010-01-27" "2010-10-04" ... $ los : num 4 3 4 25 6 3 6 2 2 3 ... I need to be able to tell at any given time how many patients (and which patients) were admitted. That is, I think I need to find out the overlap between the

Overlapping lists function returns False when True in python

柔情痞子 提交于 2020-01-06 04:21:07
问题 I'm a programming semi-noob and am working through Torbjoern Lager's 46 Simple Python Exercises. This is number 10: Define a function overlapping() that takes two lists and returns True if they have at least one member in common, False otherwise. You may use your is_member() function, or the in operator, but for the sake of the exercise, you should (also) write it using two nested for-loops. def over(list1,list2): for i in list1: for j in list2: return i==j I thought I had a nice, simple

Accruing over time (non-overlapping) - technique?

被刻印的时光 ゝ 提交于 2020-01-04 05:44:08
问题 I'm trying to find a better way of doing a Crystal Report (Someone Else's)... Add up non-overlapping time in groups. This is evidently an age-old problem... Is there a technique of getting Adjusted (start/end) times, per record, to remove common/over-lap time, within subgroups --using straight SQL (although I find I can do CTEs) Assume initial order-by for Start Time (and/or Group, SubGroup) and Start and End are separate fields. A kind-a graphic example: Group 1 SubGroup A Tkt 1 |--start&end

SQL - Consolidate Overlapping Data

浪子不回头ぞ 提交于 2020-01-03 17:29:07
问题 I have a simple data set in SQL Server that appears like this **ROW Start End** 0 1 2 1 3 5 2 4 6 3 8 9 Graphically, the data would appear like this What I would like to achieve is to collapse the overlapping data so that my query returns **ROW Start End** 0 1 2 1 3 6 2 8 9 Is this possible in SQL Server without having to write a complex procedure or statement? 回答1: Here's the SQL Fiddle for another alternative. First, all the limits are sorted by order. Then the "duplicate" limits within an

SQL - Consolidate Overlapping Data

天涯浪子 提交于 2020-01-03 17:27:21
问题 I have a simple data set in SQL Server that appears like this **ROW Start End** 0 1 2 1 3 5 2 4 6 3 8 9 Graphically, the data would appear like this What I would like to achieve is to collapse the overlapping data so that my query returns **ROW Start End** 0 1 2 1 3 6 2 8 9 Is this possible in SQL Server without having to write a complex procedure or statement? 回答1: Here's the SQL Fiddle for another alternative. First, all the limits are sorted by order. Then the "duplicate" limits within an

Deconvoluting intervals into position information

筅森魡賤 提交于 2020-01-03 03:24:07
问题 I have fileA in which the information is displayed by intervals - if consecutive positions are assigned the same value, these consecutive values are regrouped into one interval. start end value label 123 78000 0 romeo #value 0 at positions 123 to 77999 included. 78000 78004 56 romeo #value 56 at positions 78000, 78001, 78002 and 78003. 78004 78005 12 romeo #value 12 at position 78004. 78006 78008 21 juliet #value 21 at positions 78006 and 78007. 78008 78056 8 juliet #value 8 at positions

Convert data of overlapping time ranges to data of distinct time ranges

。_饼干妹妹 提交于 2020-01-02 23:06:11
问题 I have data that consists of observations of the range of time a particular status applied for an individual. An individual can have multiple statuses at a given time, or have no stats at all (in which case there would not be an observation). ID STATUS START END 1 A 2013-03-07 2013-04-20 1 B 2013-04-10 2013-05-10 1 C 2013-04-16 2013-07-11 1 B 2013-07-25 2013-08-08 2 A 2013-09-10 2014-04-21 2 C 2013-12-27 2014-01-26 2 D 2014-04-28 2014-05-10 2 E 2014-05-11 2014-07-16 I would like to convert

How to remove overlap in numeric ranges (AWK)

老子叫甜甜 提交于 2020-01-02 14:56:33
问题 I'm trying to remove the overlap within a file. There's a bunch of records that starts with an 'A' and which have a 'start-value' and an 'end-value'. There's also a bunch of records that start with a 'B', also has range and that shows a possible overlap with records starting with 'A'. The idea is to remove the overlapping range from A so only non-overlapping ranges exist. Some of the records in B have an identical 'start-value' while others have an identical 'end-value' with A. So, if A has a

How do I compare overlapping values within a row?

青春壹個敷衍的年華 提交于 2020-01-02 08:12:39
问题 I seem to have a problem with this SQL query: SELECT * FROM appts WHERE timeStart >='$timeStart' AND timeEnd <='$timeEnd' AND dayappt='$boatdate' The time is formatted as military time. The logistics is that a boat rental can be reserved at 7am til 1pm or 9am til 1pm or 9am til 5pm. If there is an appt within that range, it should return appts but it has proven to be inconsistent. If I pick 9am til 1pm, it will ignore appts that started with 7am even though it overlaps 9am-1pm. If I pick 9 to

R Find overlap among time periods

岁酱吖の 提交于 2020-01-01 18:18:29
问题 after a lot fo thinking and googling I could not find the solution to my problem, I hope you can help me. I have a large data frame with an ID column that can repeat more than 2 times, a start and and end date column that would make up a time period. I would like to find out, grouping by ID, if any of the time periods for that ID overlap with another one, and if so, flag it by creating a new column for example, saying if that ID has overlaps or not. Here is an example data frame already with