Questions tagged [group-summaries]
69 questions
2
votes
1 answer
Is there a way to get 'weighted mean' in reactable groupBy in a shiny app?
I want to generate a reactable in my app, group the table using the groupBy argument and in the groups get the weighted mean for each one.
The function reactable::colDef() offers a list of options of summary: mean, sum, max, min, median, count,…

Guilherme Fonseca
- 75
- 4
2
votes
2 answers
Weighted sum of multiple columns in R using tidyverse
I'm trying to produce a weighted sum per factor level. I have four columns of data:
col1 = surface area
col 2 = dominant
col 3 = codominant
col 4 = sub
1 2 3 4
125 A NA NA
130 A NA B
150 C B NA
160 B NA NA
90 …

Stevestingray
- 399
- 2
- 12
2
votes
4 answers
Reshaping data with dates as column values
I am trying to reshape data using pandas and have been having a hard time getting it into the right format. Roughly, the data look like this*:
df = pd.DataFrame({'PRODUCT':['1','2'],
…

jason.f
- 67
- 1
- 6
2
votes
2 answers
Get group mean with multiple grouping variables and excluding own group value
I'm looking for a faster way to calculate a group mean with multiple grouping variables while excluding own group values. A thought experiment would be finding average value (e.g. price) for a county from the counties in the same state in the same…

qnp1521
- 806
- 6
- 20
2
votes
2 answers
How to add a weighted average summary to a DevExpress XtraGrid?
The DevExpress Grid (XtraGrid) allows grids and their groups to have summary calculations. The available options are Count, Max, Min, Avg, Sum, None and Custom.
Has anyone got some sample code that shows how to calculate a weighted average column,…

Drew Noakes
- 300,895
- 165
- 679
- 742
2
votes
4 answers
Adding summary row based on category in Sqlite
Is it possible to add summary in rows with group by: To be specific i am looking for the below output.
Main Table
Client|Billing
--------------
a | 34
a | 27
b | 29
b | 27
c | 28
c | 37
Output should look alike:…

ayush varshney
- 517
- 7
- 20
2
votes
1 answer
Relative frequencies with dplyr with dynamically created columns pertaining to each group
I'm following very useful solution on creating a summary column for multiple categories. As discussed in the linked solution, I am working with a code that generates the percentage column for each subgroup.
Relevant sample code from the linked…

Konrad
- 17,740
- 16
- 106
- 167
2
votes
1 answer
R - Dplyr - How to add a calculated field based on current data.frame
I'm grouping a data frame by the column "month", and then summarising the "users" column.
Using this code:
Count_Users_By_Month <- Users_By_Month %>% group_by(month) %>%
summarise(Users = length(unique(users)))
I get this, that i'm 100% sure…

Omar Gonzales
- 3,806
- 10
- 56
- 120
2
votes
1 answer
data.table result of by and join not sorted as I expected, why? Is it for efficiency?
I just discovered that summarizing a data table (I am relatively new to r and data.table) doesn't result in a sorted data tabe, nor does a join:
starting data table:
> DailyDataICount
ID week WeekDay Qty
1: …

user3645882
- 739
- 5
- 11
1
vote
1 answer
Merging and sum up items in looping trough nested lists
Need your help, to solve strugle with list of lists filtering, merging and summarizing. My input params:
Nested list structure [p0-n, p1-n, p2-n, q3, q4, q5] n - num
Items using for filtering and merging (p0 and p1 and p2)
Summarize (q3, q4, q5)…

Dmitry R.
- 11
- 2
1
vote
1 answer
How to combine summarize_at and custom function that requires input from multiple columns in R?
I have a list of employees actual capacity (which changes each month) and their scheduled capacity (which is constant every month). I want to use summarize_at to tell what percentage they are over (or under) their allocation. However, I can't figure…

J.Sabree
- 2,280
- 19
- 48
1
vote
1 answer
Applying a dplyr function to all variables at once
I have a dataframe with a numeric variable ("numeric") and several factor variables (factors 0 and 1 (FALSE, TRUE) or 0 to 4 (states in a pathology)). I would like to summarise median and IQR for "numeric" for each of the groups (0 to 1, 0 to…

dracoplasma
- 13
- 3
1
vote
1 answer
Using across function in dplyr
I have a dataframe which contains missing values.
# Create dataframe
df <- data.frame(Athlete = c(c(replicate(200,"Ali"), c(replicate(200,"Tyson")))),
Score = replicate(400, sample(c(1:20, NA), 1, rep = TRUE)))
My function groups…

Brad
- 580
- 4
- 19
1
vote
2 answers
Summarizing Dataframe containing numbers and strings by latitude
I would like to be able to calculate the average "IntakeEnergy" by location (latitude) for the following dataset. The problem that I think I am having is that the dataset contains both number and characters which results in the function not knowing…

Devin Mendez
- 101
- 8
1
vote
2 answers
Calculating upper and lower confidence intervals by group in dplyr summarise()
I am trying to make a table that shows N (number of observations), percent frequency (of answers > 0), and the lower and upper confidence intervals for percent frequency, and I want to group this by type.
Example of data
dat <- data.frame(
"type"…

cgxytf
- 421
- 4
- 11