group-summaries

How to add a weighted average summary to a DevExpress XtraGrid?

 ̄綄美尐妖づ 提交于 2019-12-04 16:10:44
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, based upon the weightings provided as values in another column? I ended up working this out, and will post my solution here in case others find it useful. If a weighted average consists of both a value and a weight per row, then column that contains the value should have the weight GridColumn object assigned to its Tag property. Then, this event

Parallel wilcox.test using group_by and summarise

杀马特。学长 韩版系。学妹 提交于 2019-12-03 15:06:39
There must be an R-ly way to call wilcox.test over multiple observations in parallel using group_by. I've spent a good deal of time reading up on this but still can't figure out a call to wilcox.test that does the job. Example data and code below, using magrittr pipes and summarize() . library(dplyr) library(magrittr) # create a data frame where x is the dependent variable, id1 is a category variable (here with five levels), and id2 is a binary category variable used for the two-sample wilcoxon test df <- data.frame(x=abs(rnorm(50)),id1=rep(1:5,10), id2=rep(1:2,25)) # make sure piping and

Aggregate by multiple columns and reshape from long to wide

夙愿已清 提交于 2019-11-29 17:39:09
There are some questions similar to this topic on SO but not exactly like my usecase. I have a dataset where the columns are laid out as shown below Id Description Value 10 Cat 19 10 Cat 20 10 Cat 5 10 Cat 13 11 Cat 17 11 Cat 23 11 Cat 7 11 Cat 14 10 Dog 19 10 Dog 20 10 Dog 5 10 Dog 13 11 Dog 17 11 Dog 23 11 Dog 7 11 Dog 14 What I am trying to do is capture the mean of the Value column by Id, Description. The final dataset would look like this. Id Cat Dog 10 14.25 28.5 11 15.25 15.25 I can do this in a very rough manner not very efficient like this tempdf1 <- df %>% filter(str_detect