intervals

Splitting a data frame into a list using intervals

烈酒焚心 提交于 2019-12-13 01:24:43
问题 I want to split a data frame like this chr.pos nt.pos CNV 1 74355 0 1 431565 0 1 675207 0 1 783605 1 1 888149 1 1 991311 1 1 1089305 1 1 1177669 1 1 1279886 0 1 1406311 0 1 1491385 0 1 1579761 0 2 1670488 1 2 1758800 1 2 1834256 0 2 1902924 1 2 1978088 1 2 2063124 0 The point is to get a list of intervals where the chr are the same and CNV=1 column, but taking into account the 0 inervals between them [[1]] 1 783605 1 1 888149 1 1 991311 1 1 1089305 1 1 1177669 1 [[2]] 2 1670488 1 2 1758800 1

Android make method run every X seconds (involves gps and server call)

强颜欢笑 提交于 2019-12-12 20:11:59
问题 I have a niche application that needs to send a server its location every few seconds. (Don't worry about a mobile phone's battery life). How would I make a thread or something execute every few seconds? I have a gpslistener but the name of its subclass is "onlocationchanged" which seems to only want to provide information if the location changed, I will need an updated location sent to the server every time though on an interval that I define How would I do this? insight appreciated 回答1:

Is it okay to use Thread.sleep() in a loop in Java, to do something at regular intervals?

半城伤御伤魂 提交于 2019-12-12 10:30:54
问题 I have read some threads that said that calling Thread.sleep() in a loop is problematic and is a serious performance issue. But in some cases it seems the most natural thing to do. For example if I want my application to do something every 3 minutes (lets say it's an autosave ) public void startAutosaveLoop(){ stop = false; new Thread(new Runnable() { @Override public void run() { while (!stop){ Thread.sleep(T*1000); if (!stop){ // do something } } } }).start(); } Is there a better way to

Plotting a 95% confidence interval for a lm object

青春壹個敷衍的年華 提交于 2019-12-12 09:05:13
问题 How can I calculate and plot a confidence interval for my regression in r? So far I have two numerical vectors of equal length (x,y) and a regression object(lm.out). I have made a scatterplot of y given x and added the regression line to this plot. I am looking for a way to add a 95% prediction confidence band for lm.out to the plot. I've tried using the predict function, but I don't even know where to start with that :/. Here is my code at the moment: x=c(1,2,3,4,5,6,7,8,9,0) y=c(13,28,43,35

How to color unequal intervals of a plot line using R

自闭症网瘾萝莉.ら 提交于 2019-12-12 06:24:29
问题 I would like to color X-axis intervals of a plot line with different colours between these points: 52660, 106784, 151429, 192098, 233666, 273857, 307933, 343048, 373099, 408960, 441545, 472813, 497822, 518561, 537471, 556747, 571683, 591232, 599519, 616567, 625727, 633745 The intervals represent SNP positions along 22 chromosomes. The problem is that the intervals are unequal (e.g. 52660 - 106784, 106784 - 151429, ... 472813 - 497822, ...). Y-axis values represent ancestry frequencies. X-axis

Create scatter plot with interval data in R

*爱你&永不变心* 提交于 2019-12-12 04:34:50
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 2 years ago . The answer to this question is probably more than obvious, but I just cannot get my head around (or rather, I think I know a solution, but it appears to complicated to me), so I thought I should ask for help. My data looks like this: MyItem Measurement First Last Item1 10 267.4 263.2 Item2 15 263.2 254.8 Item3 3 250.5 250.5 Item4 20 266.9 253.2 Item5 16 260.0 250.0 My

How to group dates within a certain time interval

不羁的心 提交于 2019-12-12 02:58:13
问题 I have an array of dates and i would like to discard any dates that don't have at least one another date in a specific time interval, for example 5 minutes. I need to find a smart way to do it, as loops take forever with a larger dataset. input data: 2009 07 07 16:01:30 2009 07 07 16:04:06 2009 07 07 16:05:00 2009 07 07 16:12:00 2009 07 07 16:19:43 2009 07 07 16:24:00 results: 2009 07 07 16:01:30 2009 07 07 16:04:06 2009 07 07 16:05:00 2009 07 07 16:19:43 2009 07 07 16:24:00 The value 2009 07

Overlapping time intervals WITHOUT for/while loops

你。 提交于 2019-12-12 02:24:35
问题 The best way to ask my question is via a clear example. Consider 2 timelines (e.g. time in seconds) A and B where the intervals for each timeline are: intervals_a = 0 1 1 4 4 7 7 9 intervals_b = 0 2 2 3 3 5 5 8 Notice that the first a-interval overlaps the first b-interval. The second a-interval overlaps the first, second, and third b-intervals, and so on. Ultimately, I need an output which shows the indices of a-intervals which overlap with b-intervals as below: output = 1 1 \\ 1st a

Setting random Timer intervals in VB

人走茶凉 提交于 2019-12-12 02:14:59
问题 My goal is to make code that will beep randomly anywhere from 1 to 30 seconds apart. Here is my code so far: Public Class Form1 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Console.Beep() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Stop() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Role on dynamic google chart (interval)

夙愿已清 提交于 2019-12-12 02:06:26
问题 How can I use this: https://developers.google.com/chart/interactive/docs/roles if I populate the graph dynamically? This is part of my code: ... data.addRows(dates.length); for (i = 0; i < dates.length; i++){ if (i!=0){ data.setValue( i, 0, new Date(dates[i]) ); temp = graph[dates[i]]; var j = 0; if (temp){ for (j = 0; j < groups.length; j++){ if ( groups[j] in temp){ var volume = parseFloat(temp[groups[j]]); console.log(i + ' ' + j + ' ' + volume); data.setValue( i, j+1, volume ) } } } }else