Tag aggregate

[Solved] Joins and/or Sub queries or Ranking functions

Using max(ship_num) is a good idea, but you should use the analytic version (with an OVER clause). select * from ( select t.*, max(ship_num) over (partition by order_id) as orders_max_ship_num from table1 t1 ) with_max where ship_num = orders_max_ship_num order…

[Solved] Multiple aggregation in R with 4 parameters

You could try something like this in data.table data <- data.table(yourdataframe) bar <- data[,.N,by=y] foo <- data[x==1 & z==1,list(mean.t=mean(t,na.rm=T),median.t=median(t,na.rm=T)),by=y] merge(bar[,list(y)],foo,by=”y”,all.x=T) y mean.t median.t 1: 1 12.5 12.5 2: 2 NA NA 3: 3 NA NA 4: 4 NA NA You…

[Solved] Using R – Read CSV , aggregate/percent column

The first step (reading in the csv) is pretty simple: data = read.table(“filename.csv”, sep = “,”, quote = “”, header=TRUE) The ‘sep’ part makes it clear that the separator is a comma, and ‘header’ keeps those column headings separate from…