Questions tagged [group]

585 questions
-1
votes
1 answer

How to select the most frequent value for each group within two tables?

I have two tables and I want to select the most ordered (amount) product for each shipmentType (see result table) shipment…
ahm5
  • 633
  • 5
  • 9
-1
votes
1 answer

How do you group data with the same name in a vector?

I have a DataFrame with three columns:region, year, grdp. How do I group data with the same name in 'region' column. Here's the code to create a sample dataset: Here's the desired result: store data of values with the same name in the 'region'…
김준서
  • 1
  • 1
-1
votes
1 answer

Combination with conditions in R

how to make a combination of letters label=c("A","B","C","D","E") into a dataframe with 4 group (G1, G2, G3, G4) as follows k2=data.frame(G1=c("AB","AC","AD","AE","BC","BD","BE","CD","CE","DE"), G2=c("C","B","B","B","A","A","A","A","A","A"), …
Michele
  • 29
  • 1
-1
votes
2 answers

get the no. of observations in every level of factor after grouping by factors

in the data Arthritis of package 'vcd', after grouping by Treatment and Sex, i would like to get the no. and percentage of observations in every level (None, Some, Marked) of Improved. how to do it?
汪燕敏
  • 23
  • 3
-1
votes
1 answer

Create groups in data frame based upon whether next value reaches a threshold

I have df with a column diff_index. I'd like to create a grouping column based on whether the next value is greater than a threshold x - if the next value is greater than x, then I want a new group. So in this case, if the threshold is 100, the…
user438383
  • 5,716
  • 8
  • 28
  • 43
-1
votes
2 answers

Only keep the minimum value of each group

I have the following data.table:- > dataz <- data.table(group = c("ZAS", "Car", rep("EEE", times = 3), rep("EEff", times = 2), rep("2133", times = 6), "EETTE"), value = runif(14)) > dataz group value 1: ZAS…
Shawn Brar
  • 1,346
  • 3
  • 17
-1
votes
1 answer

Group by an element

So I have a dataframe on Python that has lots of variables happening at once and getting pulled off at the same time and I want to make them into a new dataframe thats grouped by time so for example its…
-1
votes
3 answers

Subset a dataframe - grouped and multiple values R

I am trying to subset a dataframe by multiple values in one column. The input is the following: Output should be: So i want only the rows in the new dataframe, which contains 0 AND 1 in the column "Auto" - grouped for each shop. Already tried…
user17549713
  • 84
  • 1
  • 10
-1
votes
2 answers

Postgres SQL query group by get most recent record instead of an aggregate

This is a current postgres query I have: sql = """ SELECT vms.campaign_id, avg(vms.open_rate_uplift) as open_rate_average, avg(vms.click_rate_uplift) as click_rate_average, avg(vms.conversion_rate_uplift) as…
tonyyyy
  • 21
  • 3
-1
votes
2 answers

calculate average in separate column over period and group by date Standard SQL BigQuery

I have a table in BQ that looks like this: date rate 02/02/22 null 02/01/22 null 01/31/22 1 01/30/22 1.5 01/29/22 0.5 I want to create avg_rate column. I tried simple calculations for averages but because…
Chique_Code
  • 1,422
  • 3
  • 23
  • 49
-1
votes
1 answer

Generating group mean for a continuous variable in stata

I have percent change of a variable for 20 years. I want to find the average percent change for 3 years continuously over the 20 years. So, suppose I have the data from 2000-2020. I want to form the average of 2000,2001,2002, then, 2001,2002,2003,…
-2
votes
1 answer

Required Comment in New Column based on criteria of other columns in power query

This is a table where I need to find out which invoice material batches were used sequentially or not sequentially, in simple words to find out which invoices were billed in multiple batches in a single invoice Whether or not the FEFO method was…
Amar Gunjal
  • 39
  • 1
  • 6
-2
votes
1 answer

Aggregation of query in sql

I have table, like: Id Account Date Amount 1. ad@ind 07.11.2022 354 2. ad@ind 10.11.2022 586 I need to find record, where is maximum number of month and get amount in this date. How is it to do? Max(date) does'nt fit, i need number…
-2
votes
1 answer

How can I group values in arrays and count them in PHP for use in a Highchart?

I have two arrays that contain the value. $list_partners_edr = Array ( [0] => AIDA [1] => AMAN [2] => CDS [3] => CISForm [4] => ICJ Makassar [5] => ICJR [6] => IJRS [7] => Kemitraan [8] => LBH APIK [9] => LBH…
-2
votes
1 answer

Create a new row in a dataframe that is a calculation based on existing rows

enter image description here In the attached image I would like to create and add the c variable rows rto the dataframe. Row c is row a - row b (by date etc). Have tried using dplyr but not getting there.... variable <- c(a,b,a,b) date <- c(jan…
1 2 3
38
39