intervals

Counting overlaps as expected with R data.table foverlaps() or IRanges

风流意气都作罢 提交于 2020-06-27 12:44:05
问题 I'm having difficulty counting overlaps of intervals as I would expect. Here is an R data.table with intervals defined by start to end: > library(data.table) > dt1 = data.table(start=c(1, 5, 3), end=c(10, 15, 8)) > print(dt1) start end 1: 1 10 2: 5 15 3: 3 8 Here is how I would consider overlaps for these intervals, from 0 to 20: [0, 1]: 0 (there are no intervals here) [1, 3]: 1 (there is only one interval here, from [1, 10]) [3, 5]: 2 (two intervals here, both [1, 10] and [3, 8]) [5, 8]: 3

match with an interval and extract values between two matrix R

余生长醉 提交于 2020-04-14 08:03:31
问题 I have n matrix in a list and an additional matrix which contain the value I want to find in the list of matrix. To get the list of matrix, I use this code : setwd("C:\\~\\Documents\\R") import.multiple.txt.files<-function(pattern=".txt",header=T) { list.1<-list.files(pattern=".txt") list.2<-list() for (i in 1:length(list.1)) { list.2[[i]]<-read.delim(list.1[i]) } names(list.2)<-list.1 list.2 } txt.import.matrix<-cbind(txt.import) My list look like that: (I show only an example with n=2). The

How do I write a method that finds all the intersections in an array of ranges?

跟風遠走 提交于 2020-03-03 09:14:08
问题 I have array similar to this [ [0, 10]**, [1, 3]**, [5, 11]**, [14, 20]**, [10, 11]** ] ** Denotes an object containing the start and end indexes shown in the array Now, the intersections are [1, 3], [5,10], [10,11] What is the best way to write a method that returns the objects containing of the intersecting sets? (Could just store them in an array of conflicted stuff as we go along) The biggest issue I'm having is how do I do this such that each object is compared with eachother object?

Date interval sum and subtraction in Java

安稳与你 提交于 2020-02-23 10:14:02
问题 I'm looking for a library or helper class in Java that would allow me to perform date interval sum and subtractions. For example, lets's say I have the following date intervals: A = ["2015-01-01 00:00", "2015-01-20 00:00"] B = ["2015-01-05 00:00", "2015-01-10 00:00"] C = ["2015-01-11 00:00", "2015-01-14 00:00"] D = ["2015-01-19 00:00", "2015-01-25 00:00"] 1 A 20 |----------------------------------| |---------| |----------| |------------| 5 B 10 11 C 14 19 D 25 And let's say I'd like to

Date interval sum and subtraction in Java

旧城冷巷雨未停 提交于 2020-02-23 10:12:30
问题 I'm looking for a library or helper class in Java that would allow me to perform date interval sum and subtractions. For example, lets's say I have the following date intervals: A = ["2015-01-01 00:00", "2015-01-20 00:00"] B = ["2015-01-05 00:00", "2015-01-10 00:00"] C = ["2015-01-11 00:00", "2015-01-14 00:00"] D = ["2015-01-19 00:00", "2015-01-25 00:00"] 1 A 20 |----------------------------------| |---------| |----------| |------------| 5 B 10 11 C 14 19 D 25 And let's say I'd like to

How I can select / sort dates by period intervals?

大城市里の小女人 提交于 2020-02-02 12:50:47
问题 For ex: If we have in table records like: 25/06/2009 28/12/2009 19/02/2010 16/04/2011 20/05/2012 I want to split/select this dates according to 6 month intervals starting from current date. result should be like: 0-6 month from now: first record 7-12 month from now: second record ... It will be much apreciated if you make this simple as I made it very stupid and complicated like: declare variable like t1=curdate()+6 t2=curdate()+12 ... then selected records to fit between curdate() and t1,

MySQL: select last full 5 minute interval

情到浓时终转凉″ 提交于 2020-01-24 12:10:14
问题 I want to select from my table the last full 5 minute interval. Example: Time now: 09:32 am --> select --> 09:25 - 09:30 am Time now: 10:44 pm --> select --> 10:35 - 10:40 pm I know how to group my select into 5 minute intervals date_sub(date_sub(starttime, INTERVAL (MINUTE(starttime) % 5) MINUTE), INTERVAL (SECOND(starttime)) SECOND) as INTERVAL_START, date_add(date_sub(date_sub(starttime, INTERVAL (MINUTE(starttime) % 5) MINUTE), INTERVAL (SECOND(starttime)) SECOND), INTERVAL 5 MINUTE) as

How to manipulate (aggregate) the data in R?

我与影子孤独终老i 提交于 2020-01-24 11:53:21
问题 I have a data set as I've shown below: df <- tribble( ~id, ~price, ~number_of_book, "1", 10, 3, "1", 5, 1, "2", 7, 4, "2", 6, 2, "2", 3, 4, "3", 4, 1, "4", 5, 1, "4", 6, 1, "5", 1, 2, "5", 9, 3, ) As you see in the data set, there are 3 books which cost 10 dollar for each book if id is "1" and 1 book that costs 5 dollar. Basically, I want to see the share (%) the number of books for each price bin. Here is my desired data set: df <- tribble( ~id, ~less_than_three, ~three-five, ~five-six,

How to manipulate (aggregate) the data in R?

↘锁芯ラ 提交于 2020-01-24 11:51:39
问题 I have a data set as I've shown below: df <- tribble( ~id, ~price, ~number_of_book, "1", 10, 3, "1", 5, 1, "2", 7, 4, "2", 6, 2, "2", 3, 4, "3", 4, 1, "4", 5, 1, "4", 6, 1, "5", 1, 2, "5", 9, 3, ) As you see in the data set, there are 3 books which cost 10 dollar for each book if id is "1" and 1 book that costs 5 dollar. Basically, I want to see the share (%) the number of books for each price bin. Here is my desired data set: df <- tribble( ~id, ~less_than_three, ~three-five, ~five-six,

Hadoop: intervals and JOIN

我是研究僧i 提交于 2020-01-23 02:39:06
问题 I'm very new to Hadoop and I'm currently trying to join two sources of data where the key is an interval (say [date-begin/date-end]). For example: input1: 20091001-20091002 A 20091011-20091104 B 20080111-20091103 C (...) input2: 20090902-20091003 D 20081015-20091204 E 20040011-20050101 F (...) I'd like to find all the records where the key1 overlaps the key2. Is it possible with hadoop ? Where can I find an example of implementation ? Thanks. 回答1: A solution was given on Biostar: http:/