range

Javascript get range compared to a parent element

泄露秘密 提交于 2020-01-16 04:13:31
问题 I have a function that return an array (won't work in IE) with two elements the html code of what the user select inside a div (id=text) the range of the selection In case the user select a simple string inside the text div the range return the correct values but when the user select a string inside an element child of div (div#text->p for example) range's values are related to the child element but i want them to be related to the parent (div#text) Here there's a JsFiddle http://jsfiddle.net

PostgreSQL aggregate function over range

不想你离开。 提交于 2020-01-15 11:53:10
问题 I am trying to create a function that will find the intersection of tsrange , but I can't get it work: CREATE AGGREGATE intersection ( tsrange ) ( SFUNC = *, STYPE = tsrange ) 回答1: There are two modifications to your attempt. First, I don't think you can use an operator as the SFUNC, so you need to define a named function to do the intersection, and use that. CREATE or REPLACE FUNCTION int_tsrange(a tsrange, b tsrange) returns tsrange language plpgsql as 'begin return a * b; end'; Secondly,

Ranges surrounding values in data frame R dplyr

天涯浪子 提交于 2020-01-15 07:16:12
问题 I have a data frame that looks something like this : test <- data.frame(chunk = c(rep("a",27),rep("b",27)), x = c(1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1)) There is a column by which I would like to group the data using group_by() in dplyr , which in this example is called chunk I want to add another column to each chunk of test called x1 so the resulting data frame looks like this : test1 <- data.frame(test, x1 = c(0,0,0,0,0

Nearest neighbors in a given range

社会主义新天地 提交于 2020-01-15 04:01:08
问题 I faced the problem of quickly finding the nearest neighbors in a given range. Example of dataset: id | string | float 0 | AA | 0.1 12 | BB | 0.5 2 | CC | 0.3 102| AA | 1.1 33 | AA | 2.8 17 | AA | 0.5 For each line, print the number of lines satisfying the following conditions: string field is equal to current float field <= current float - del For this example with del = 1.5: id | count 0 | 0 12 | 0 2 | 0 102| 2 (string is equal row with id=0,33,17 but only in row id=0,17 float value: 1.1-1

Excel MATCH range without specific CELL

拜拜、爱过 提交于 2020-01-14 22:46:07
问题 after a deep search on the internet i gave up. My "simple" question would be: How can I add two ranges in a formula, preferably in MATCH? I want to search a range like A1:A7 + A9:A20 and thus not include A8 in my range. Is this possible? Please help me out 回答1: Natively you can't but you could try to bypass it with either: Exclude a single cell: If you want to exclude a certain cell from a MATCH you can exclude it's certain row number like so: =MATCH(1,(A1:A20="X")*(ROW(A1:A20)<>8),0) Or

Java - Average Linear Graph Plots

强颜欢笑 提交于 2020-01-14 14:13:58
问题 I have a piece of code that checks if the given 3 coordinates are linear to one another (if so, return true). But is there a way to make the code give or take a few pixels/plots? private boolean collinear(double x1, double y1, double x2, double y2, double x3, double y3) { return (y1 - y2) * (x1 - x3) == (y1 - y3) * (x1 - x2); } You see, the coordinates have to be exactly inline for it to register as linear. How will I be able to make it look within a 'range' of some kind, for it to check

Excel 2013 VBA Range.RemoveDuplicates issue specifying array

拟墨画扇 提交于 2020-01-14 14:13:18
问题 The sheets that I am scanning for duplicates have different numbers of columns I'm trying to specify the array of columns for Range.RemoveDuplicates by using a string like this: Let's say there are 5 columns in this sheet Dim Rng As Range Dim i As Integer Dim lColumn As Integer Dim strColumnArray As String With ActiveSheet lColumn = Cells(1, Columns.Count).End(xlToLeft).Column strColumnArray = "1" For i = 2 To lColumn strColumnArray = strColumnArray & ", " & i Next i 'String ends up as "1, 2,

Django REST framework range filter

二次信任 提交于 2020-01-14 12:39:55
问题 How can I do a range filter for dates and number in Django REST Framework? Other filters (lt, gt etc.) work fine. I tried many variants such as: import rest_framework_filters as filters class OrderFilter(filters.FilterSet): total_price__range = filters.RangeFilter(name='total_price') created_at__range = filters.DateFromToRangeFilter(name='created_at') .... class Meta: model = Order fields = { 'created_at__range': ['__all__'], 'total_price__range': ['__all__'], ... } class OrderViewSet

Django REST framework range filter

空扰寡人 提交于 2020-01-14 12:39:45
问题 How can I do a range filter for dates and number in Django REST Framework? Other filters (lt, gt etc.) work fine. I tried many variants such as: import rest_framework_filters as filters class OrderFilter(filters.FilterSet): total_price__range = filters.RangeFilter(name='total_price') created_at__range = filters.DateFromToRangeFilter(name='created_at') .... class Meta: model = Order fields = { 'created_at__range': ['__all__'], 'total_price__range': ['__all__'], ... } class OrderViewSet

Intersecting ranges of consecutive values in logical vectors in R

跟風遠走 提交于 2020-01-14 10:23:29
问题 I have two logical vectors which look like this: x = c(0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0) y = c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) I would like to count the intersections between ranges of consecutive values. Meaning that consecutive values (of 1s) are handled as one range. So in the above example, each vector contains one range of 1s and these ranges intersect only once. Is there any R package for range intersections which could help here? 回答1: I think this should work (calling your