Questions tagged [group-summaries]

69 questions
1
vote
2 answers

Group by relative difference in a column (accounting for how data is ordered)

I have a data frame. The snippet is: df1 <- data.frame(x = c(1, 2, 1, 3, 5, 1, 4, 1), y = c(1, 1, 2, 2, 1, 1, 1, 3)) x y 1 1 1 2 2 1 3 1 2 4 3 2 5 5 1 6 1 1 7 4 1 8 1 3 I need to group df1 by y and sum over x but accounting for order of y. I.e I…
drastega
  • 1,581
  • 5
  • 30
  • 42
1
vote
4 answers

Is there a dplyr function to determine the most commonly encountered categorical value within a group?

I am looking to summarize a customer transactional dataframe to a single row per customer using dplyr. For continuous variables this is simple - use sum / mean etc. For categorical variables I would like to choose the "Mode" - i.e. the most…
Brisbane Pom
  • 521
  • 7
  • 18
1
vote
1 answer

'Can't create call to non-callable object' error while summarizing data by grouping

I have the following data frame: df <- data.frame(NR_HH = c('HH1','HH1','HH1','HH1','HH2','HH2'), ID = c(11,12,13,14,21,22), Age = c(28,25,16,4,45,70), Fem_Adult = c('FALSE','TRUE','FALSE','FALSE', 'TRUE','TRUE'),Male_Adult =…
1
vote
2 answers

How to dplyr::arrange groups within a df by the mean of group measure?

Building off of Kara Woo's https://stackoverflow.com/a/26555424/9350837 answer, I'm looking to sort my grouped df by the mean of respective groups summarized measure, vizCredPrcnt. This is my code, thus far, credData <- ReShapeAdCredSubset…
ajmasnyj
  • 13
  • 4
1
vote
3 answers

How to find minimum within group value greater than certain value in r

I have the following data frame: PATIENT_ID VALUE 1 8 1 16 1 24 2 50 2 56 3 2 3 70 Now I want to find all PATIENT_IDs that have a minimum that is greater than 48. In…
Peter Lawrence
  • 719
  • 2
  • 10
  • 20
1
vote
3 answers

In R, unexpected result from using group_by() and summarise() in dplyr

I don't quite understand how some of the groupings and summaries are built in R using dplyr package. With the reproducible example below I'm trying to first group by (PN,GOT,HID) to count distinct instances of PC1. I then regroup by (PN,GOT) to sum…
val
  • 1,629
  • 1
  • 30
  • 56
1
vote
0 answers

R: Conditional nested grouped summaries with dplyr?

Thanks to @Frank with my previous post (more details there), where I was able to use to answer some questions about a dataset on people's drinking patterns in bars: bar_name,person,drink_ordered,times_ordered,liked_it Moe’s Tavern,Homer,Romulan…
hpy
  • 1,989
  • 7
  • 26
  • 56
1
vote
1 answer

Grouping & summarizing data frame by multiple different columns in R

I don't know if I am not searching with the right terms but I can't find a post about this. I have a df : df <- data.frame(grouping_letter = c('A', 'A', 'B', 'B', 'C', 'C'), grouping_animal = c('Cat', 'Dog', 'Cat', 'Dog', 'Cat', 'Dog'), value =…
vagabond
  • 3,526
  • 5
  • 43
  • 76
1
vote
0 answers

Custom Group Summaries(Total Value, Item value)

I have a gridview summary Custom calc containing a sum total and one per item.I need to recalculate the values dynamically according to the group you created, keeping the total amount, which is already right. In DevExpress Docs, i find this:…
1
vote
1 answer

Summarize datatable by group based on nrows of other column

I know that this command below will summarize my table by adding the population by group and dividing it by the number of rows of each group. dt[, .(pop=sum(pop_ct)/sum(.N)), , by=.(geoid)] What I want to do, however, is to dived the summed…
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
1
vote
3 answers

How to create summaries of subgroups based on factors in R

I want to calculate the mean for each numeric variable in the following example. These need to be grouped by each factor associated with "id" and by each factor associated with"status". set.seed(10) dfex <-…
user3614783
  • 821
  • 6
  • 12
  • 20
1
vote
1 answer

Sum of certain Group Totals

I'm making a crystal report using Crystal Reports for VS2012 to show the amount of cord ordered to be cut during a date range. I've got everything working except one part and I'm not even sure this is possible. How the report is set up right now is…
1
vote
0 answers

Ratio of Group Level Data against Summary Data - Crystal Reports

I having trouble finding a way to ratio Summary data against Group Level data (not the detail Level) A simplified version of the problem is as follows: Say, I have two tables with a one to many relationship: stock LEFT OUTER JOIN sales ON…
Bryn
  • 103
  • 1
  • 8
0
votes
2 answers

Summarize data in Excel with VBA

I have a table in Excel with dates and values. Every day there were a number of different values. I want to summarize how many of each value there were every day. Example: From this Date Value 10/1 Blue 10/1 Blue 10/1 Red 11/1 Blue 11/1 …
Johan Lindskogen
  • 1,246
  • 1
  • 8
  • 25
0
votes
1 answer

Referencing variable names in loops for dplyr

I know this has been discussed already, but can't find a solution that works for me. I have several binary (0/1) variables named "indic___1" to "indic___8" and one continuous variable "measure". I would like to compute summary statistics for…
DrNumeri
  • 5
  • 4