Questions tagged [grouping]
The process of grouping entities into collections of associated elements.
6,812
questions
0
votes
0
answers
17
views
Using R to collapse data into groups to get new weights, but still getting an infinite range
I have a dataset of neurosurgery patients for which I am creating survival curves. I am trying to adjust my curves to match the age-sex distribution of the 2000 US population, which is included in the ...
-1
votes
0
answers
34
views
How to conditionally format cells in Excel by group?
I have a spreadsheet of identification numbers, and various results for each. I used a couple formula to see if the subject passed or failed any of a set of criteria, and now I need to go back through ...
2
votes
1
answer
40
views
Group list of objects into smallest possible number of sublists without exceeding maximum sum
I'm trying to write a method that groups objects into the minimum amount of sublists without mixing types (int field on object) or the sum of their values exceeding a defined maximum value. It should ...
2
votes
2
answers
39
views
Grouping/Clustering Rectangles
I have a list of shapes (list of points) e.g. rectangles which I want to group/cluster together.
This is what I have:
And this is what I want to achieve.
How to do it?
I already looked at some ...
-4
votes
1
answer
55
views
How to count groups string input with same character
this code is about Too Many Tabs code.
URLs are considered equal if the domains are exactly the same, e.g. google.com and google.co.id are different
Example input
google.com google.co.id facebook.com ...
0
votes
1
answer
38
views
SQL grouping data so it doesn't repeat with each row
Below is the data from the table i am querying
Below is the query that i am running, and causing duplicates. I am not sure what i am missing that is causing it.
select distinct j.Answer as Name,
...
2
votes
5
answers
47
views
Get the latest non-NA value based on date column by group
I have a dataframe having country_name, date and several columns: column_1, column_2and column_3. I am trying to extract the latest record based on date across several columns.
The dataframe looks ...
0
votes
1
answer
20
views
Penalized logistic regression with grouped data
My data is a collection of x values (shift.magnitude) and y values (response.sign) for each of a large collection of participants specified by ID. I am performing logistic regression for each ...
4
votes
5
answers
48
views
Grouping dates in R to create patient episodes?
I am working with medical claims data to create inpatient episodes. There isn't an 'episode identifier' column within the dataset. My intention is to create a unique identifier for each episode to tie ...
1
vote
2
answers
30
views
How to use string values in one column to ID and select rows from another column in the same dataframe, varying per group?
I have a data frame that contains all possible order permutations that participants could be presented with, and a column that contains a permutation ID (i.e. presentation order) that each individual ...
0
votes
1
answer
17
views
How to identify groups of interindividual revisitation?
I have an output data frame from the "recurse" package calculating the revisitation rate of several individuals based on GPS points. In the data frame I have 18 columns, including "site&...
0
votes
1
answer
38
views
Grouping then max on MSSQL Query
I have two tables as follows.
Table 1:
ID
ArtNumber
Date
Price
1
Article1
07.05.2022
100.00
2
Article2
07.05.2022
100.00
3
Article1
10.05.2022
100.00
4
Article2
10.05.2022
100.00
Table 2
ID
...
-1
votes
3
answers
96
views
Iterate nested array items and, upon the same value of a specific key, collect any other entry value as data of a merger which is grouped by key+value
I have an array that looks like this:
So as a strucutre it would be something like:
[
[
{ classNumber: '2', status: 'A', terms: [] },
{ classNumber: '32', status: 'B', terms: [] }, ...
0
votes
0
answers
20
views
Grouping Xamarin Forms Markers in Map
Hi Could any one please help with code that how can I implement Clustering of Markers in Xamarin Forms Map in Custom Renderer.
I have gone through with below link but I want to achieve via custom ...
0
votes
1
answer
37
views
JPA group by query
I have a table EMPLOYEES
EMP_ID
DEPT_ID
NAME
1
1
FSJFJF
2
1
GRFGFF
3
2
SFFKSF
4
2
DFSFSF
I want to create a map of EmployeeDTO by grouping employee data based on deptId.
public class EmployeeDTO ...
1
vote
1
answer
31
views
d3.groups by multiple keys given array of of keys
See working fiddle here: https://jsfiddle.net/0qgtbk9r/9/
Say I have an array of objects for data, and the user has supplied multiple keys to group by. I want to utilize d3.groups to group by those ...
0
votes
0
answers
30
views
Group classification considering the state and date of data with other states in the middle in R
'''library(tidyverse)'''
df=structure(list(ID = c(348L, 348L, 348L, 348L, 348L, 348L, 348L, 348L, 348L, 348L, 348L, 348L, 348L, 348L, 348L, 533L, 533L, 533L,533L, 533L, 533L, 586L, 902L, 902L, 902L, ...
-1
votes
1
answer
29
views
Group an array of objects by one of its elements
I have an array of objects that looks like this
arr = [{
group: "Forest",
value: "81.8",
year: 2015
}, {
group: "Forest",
value: "86.4",
year: 2016
}...
0
votes
1
answer
20
views
Group Dataframe rows while deleting specific columns
I have a dataframe with several columns. I want to group rows based on multiple column values.
My source dataframe looks like this:
category code color property_value price
A ...
0
votes
4
answers
86
views
Compare objects within an array and create a new array without duplicates
I've an array of objects:
[
{ name: "John", age: "34" },
{ name: "Ace", age: "14" },
{ name: "John", age: "45" },
{ name: "...
0
votes
1
answer
29
views
How to perform grouping in spark scala when key is not same
I want to calculate the total sum of the amounts corresponding to the secondary accounts and compare its value with the primary account. In the following example, the account number that begins with &...
0
votes
1
answer
41
views
Grouping data table values in intervals
I'm having a data table dt.data with more than 7000000 rows, looking like this data snippet:
dt.data <- structure(list(nbVerbrauch = c(621, 1143300, 10335, 7521, 5632,
5000, 15283, 40454, 16289, ...
1
vote
1
answer
31
views
Is there a way in R to count the number of rows where dates are consecutive after grouping?
I am trying to calculate length of stay for clients; this is not a field in the data, but each row is a separate day, with consecutive days belonging to the same "stay" - so if there are 5 ...
0
votes
2
answers
40
views
Labelling rows according to how many times the group appeared in previous rows
Suppose I have the following data.frame object:
df = data.frame(id=(1:25),
col1=c('a','a','a',
'b','b','b',
'c','c','c',
...
0
votes
1
answer
26
views
Plotting NMDS A continuous variable can not be mapped to shape ggplot2 but group variable seems to be character
I am trying to plot NMDS results using an example I found online. When I plot my group variable (which are 'S' and 'E') I get "Error in 'scale_f()': A continuous variable can not be mapped to ...
0
votes
1
answer
32
views
Find Groups by multiple cascadingly related conditions
Problem
I have some data. I would like to flag the same instance (e.g. a person, company, machine, whatever) in my data by a unique ID. The data actually has some IDs but they are either not always ...
3
votes
1
answer
64
views
Javascript Grouping by object property, when property is an array
I currently have an array of items that looks a bit like this: I want to group the items by category lookup, with the slight problem that category lookup is potentially an array, such that Parent Item ...
-1
votes
6
answers
74
views
How does one, from an array of objects, collect and aggregate the merged variant of all objects with a specific equal property value?
const portfolio = [
{ name: 'Mark', stock: 'FB' },
{ name: 'Steve', stock: 'AAPL' },
{ name: 'Tim', stock: 'AAPL' },
{ name: 'Steve', stock: 'MSFT' },
{ name: 'Bill', stock: 'MSFT' },
{ ...
-1
votes
1
answer
18
views
get list of lists from dict of lists by grouping elements at same index in every key-value pair [duplicate]
I have a dictionary
a = {'a':[1,2,3],'b':[4,5,6]}
Now, I wish to convert it into a list of lists such that
[[1,4],[2,5],[3,6]]
i.e. the 1st element of every key-value pair grouped together, ...
0
votes
3
answers
48
views
How can I group an array of objects by key and create another object inside
Does anyone know how to group an array of objects by an object key and then create a new array of objects based on the grouping? For example, I have an array of Build objects as below and I want to ...
0
votes
2
answers
48
views
Oracle - Count of number of days a value has changed
I have a requirement to write a query in Oracle as shown in the screenshots below. Any help is greatly appreciated. Thanks a lot in advance. Vadi.
Table with sample data:
CREATE TABLE fee_check (
...
0
votes
2
answers
26
views
Is there a possibility in DAX to do a distinct over several columns?
I'd like to summarize the following ID's with it's prices on a distinct bases. So that means for the ID 123 both prices get summarize cause they are different. But for the ID 789 the price should only ...
2
votes
2
answers
58
views
Python itertools.groupby with dictionaries with multiple values
I am trying to use the Python itertools.groupby function to change this list:
items = [
{'price': 5.0, 'name': 'Strawberries'},
{'price': 5.0, 'name': 'Strawberries'},
{'price': 5.0, 'name': '...
1
vote
1
answer
29
views
Calculating average rle$lengths over grouped data
I would like to calculate duration of state using rle() on grouped data. Here is test data frame:
DF <- read.table(text="Time,x,y,sugar,state,ID
0,31,21,0.2,0,L0
1,31,21,0.65,0,L0
2,31,21,1.0,...
-1
votes
1
answer
20
views
Display group header in DataGrid similar to regular row
There is such a task: to show the client records in a tabular form. These records can be grouped by one field. You need to display the group in such a way that the title and data of individual records ...
0
votes
2
answers
35
views
Grouping an array at three levels using reduce
I want to group this array at three levels, id, entryId and memberId.
This is one of many things I've tried so far & nearly does what I want. However I can't understand how to populate the members ...
0
votes
2
answers
43
views
Transform a data frame with inconsistent group widths into one with equally large groups
My Goal is to transform something like this:
df1 <- data.frame(
value1 = c(100, 100, 100, 100, 100, 100, 100),
# value2=c(a, b, c, d, e, f, g),
startgroup = c(1, 101, 351, 356, 401, 451, 451)...
0
votes
1
answer
60
views
Grouping inside of a for-loop in R
I am using a modified quantile regression function found in a scientific paper. (source: https://arxiv.org/pdf/2111.04805.pdf)
I try to apply this particular methodology to my dataset, but I would ...
0
votes
0
answers
8
views
JSON grouping by keys
here is one my challeng is that I have a json object, I want to do grouping on it like below, please help me.
I have a JSON array as :
[
{
"subscriptionId": 1,
"...
1
vote
3
answers
36
views
Group array by nested array key, and duplicate items in result
This is a bit tricky to find the right words, so hopefully showing some code will help.
I have the following (simplified) array of people and their departments. This comes from CMS data which allows a ...
1
vote
2
answers
54
views
Pandas: How to add a grouping variable based upon another column?
I have a dataframe with some id's and some dates. I want to be able to group the id's by their change in date to create a generalized "grouping_variable". In r I would do it like this:
df &...
0
votes
0
answers
15
views
Is there a way to group variables to prevent obvious correlations in correlation matrix?
For example, I want to have correlations between lengths of certain parts of a human body and weight, but don't wan't to have all correlations between the body parts themselves.
Is there a way to ...
0
votes
2
answers
42
views
SAS: How to calculate date differences between rows in grouped data
My dataset have in some instances been split into multiple rows, and I need to find these instances and recombine the rows. This requires me to calculate the difference between dates in a dataset ...
0
votes
1
answer
53
views
Removing duplicates by using the substring of attribute value in XSLT
I have an XML where duplicates can be found as the last part of <rf id>. For example in the below sample XML, <rf id ="cc_2_30"> and <rf id ="cc_3_30"> are ...
-2
votes
1
answer
38
views
How to have parent /child grouping in columns in datatable in c#
I have a table that has description , price and amount of around 100 items and people(A,B..) who have entered their closest values for items in auction , is it possible to have a parent/child grouping ...
1
vote
3
answers
49
views
How can I add a new grouping variable
How can I add another variable as a grouping variable based on the date? Here is my data:
df <- tibble(id = c(rep(1, 8), rep(2, 3)),
col = structure(c(19031, 19031, 19031, 19031, 19072,...
0
votes
0
answers
21
views
Syncfusion Grid Grouping Sort issue
I have an EJ2 grid that is grouped. Before the grid is rendered, the data from the business class is sorted by sequence number which is the requirement. When the grid renders the data, the grouping ...
2
votes
3
answers
37
views
Split a dataframe column containing delimited strings into multiple columns and retain specific portions of the split strings
I have a dataframe df which contains a single column GO. Each row in df contains either one term or multiple terms (separated by ;) and each term has a specific format - it starts with either P, C or ...
0
votes
0
answers
40
views
Pandas Grouping WIth Filter
Here is the data that I have.
title year name type \
0 Closet Monster 2015 Buffy #1 actor
1 ...
1
vote
2
answers
26
views
New column with week on week spending by store
I have a dataset that I need to track customers spending week by week based on the store.
store <- c(1,2,3,4,5,6,1,2,3,4,5,6)
week <- c(1,1,1,1,1,1,2,2,2,2,2,2)
spending <- c(10,12,14,12,11,...