aggregate

Aggregate function in R with multiple function arguments

倖福魔咒の 提交于 2019-12-12 03:17:13
问题 I have sample data.set containing climate data for different seasons: df <- data.frame(season=rep(1:5,2),year=rep(1:2,each=5), temp=c(2,4,3,5,2,4,1,5,4,3),ppt=c(4,3,1,5,6,2,1,2,2,2), samples=c(22,25,24,31,31,29,28,31,30,32)) I can determine the mean of my climate variables for each season for each year simply: aggregate(df[,c('temp','ppt')], by = list(df$season,df$year), function(x) mean(x,na.rm=T)) However, I want to determine the weighted mean of each season|year combo using variable

Java algorithm to track parts of aggregated values

北慕城南 提交于 2019-12-12 01:48:28
问题 My program have evaluate hundreds of millions of records. So the question of memory and performance are important. Lets each record has key - ticketID. Also record has field value and field source_name. In source ticketID have from 1 to many (neary 100) source_name. I need aggregate only by ticketID - receive nearly 1 million of record, but also must have possibility subtract values for specified source_name - so I have track contributes. Do exist some algorithms or data structures that allow

groupby in view of sql returns aggregate error

故事扮演 提交于 2019-12-12 01:17:39
问题 I am trying to create a view with this query as you can see here: SELECT dbo.Lines.LineNumber, dbo.Lines.DocumentNumber, dbo.Joints.JointNumber, dbo.Joints.JointSize, dbo.Joints.ShopField, dbo.Joints.WPS, dbo.WeldDetails.StateStep2 AS WeldState, dbo.Welds.WeldNumber, dbo.FitUps.FitUpNumber, MAX(dbo.WeldDetails.Id) AS WeldDetailId, MAX(dbo.FitUpDetails.Id) AS FitupDetailId, dbo.Joints.Id AS JointId, dbo.Ends.Name, dbo.Joints.THK, dbo.FitUpDetails.StateStep2 AS FitupState, dbo.Joints.Revision,

JSON parsing - group by date range with JQ

本秂侑毒 提交于 2019-12-12 01:15:59
问题 I have the following JSON data : { "data": [ {"date": "2018-08-22","value": 1}, {"date": "2018-08-30","value": 2}, {"date": "2018-09-01","value": 3}, {"date": "2018-09-22","value": 3}, {"date": "2018-09-28","value": 4}, {"date": "2018-10-18","value": 5}, {"date": "2018-10-23","value": 6} ] } I would like to use JQ to group data per month starting at the first value : My month would be : 2018 08 22 to 2018 09 21 2018 09 22 to 2018 10 21 2018 10 22 to 2018 11 21 My expected output is the

Problems with aggregating and crosstabulating data

吃可爱长大的小学妹 提交于 2019-12-12 01:13:36
问题 My data looks like this, ca 3300 rows of data: Year Location Catch 1991 0313 45100 1989 0711 323 1991 0312 1100 1991 0313 45100 1989 0711 323 1991 0312 400 1990 0313 101000 1981 0711 623 1999 0312 410 2000 0313 145100 1987 0711 323 1987 1285 770 .... Years cover the period 1977-2015, and there are approx 500 different locations, not all having data in every year. I need an output like this, summing up the catch for each cell, tabulated by location (rows) and year (columns): Location '1977'

How can I for each row calculate the sum and write the percentage of that sum near each value

耗尽温柔 提交于 2019-12-12 00:46:49
问题 I have a table: X1 X2 X3 Y1 10 12 15 Y2 45 5 23 Y3 12 47 56 How can I for each row calculate the sum and write the percentage of that sum near each value. For example: X1 percent X2 percent X3 percent Y1 10 27% 12 32% 15 40.5% Y2 45 .. 5 .. 23.. Y3 12 .. 47 .. 56.. 回答1: You could either use. If dat is the dataset ( dat is data.frame in this example) v1 <- paste0(round(prop.table(as.matrix(dat),margin=1),2)*100,"%") #suggested by @Ananda Mahto or v2 <- matrix(paste0(100*round(as.matrix(dat)

How to plotting aggregated data in kibana?

假如想象 提交于 2019-12-12 00:21:08
问题 How do i plot in kibana the data that is returned from an aggregate query in elastic search. I have tried the existing methods but could not achieve this. 回答1: Kibana does not currently have a way to display output of an aggregate request according to the bug tracker on github. It looks like maybe it's coming in 4.0. 来源: https://stackoverflow.com/questions/25618376/how-to-plotting-aggregated-data-in-kibana

Double aggregate data (Nested Aggregation) and plot in a bar chart in Kibana

社会主义新天地 提交于 2019-12-11 23:38:37
问题 Is there a way to perform a nested aggregation from Kibana (v6.7.0)? I've been looking at aggregating with buckets and sub-buckets, but to no avail. Say the data looks as follows (with ID being a string and Source also being a string : | ID | Source | =============== | a1 | srcA | | a1 | srcB | | a1 | srcC | | b2 | srcA | | b2 | srcB | | c3 | srcA | | d4 | srcA | | d4 | srcB | I'd like to visualize how many IDs are in N sources, i.e. a double aggregation. In SQL-Land, the first level of

using max() and sum()

折月煮酒 提交于 2019-12-11 23:08:36
问题 I need to find the 'name of the branch that has made the most money in 2009'. My tables are below: Rental (cid, copyid, outdate, returndate, cost) Copy (copyid, mid, bid) Branch (bid, bname, baddress) I have written the following code, and it outputs the sum of all branches, but I need the sum of the branch that made the most money. I am not sure how to join a max() and sum() function in the same query. I am using Oracle 2007. Output the branch name and sum (I get a summary of all branches

Group By / Sum Aggregate Query with Parse Cloud Code

試著忘記壹切 提交于 2019-12-11 22:15:27
问题 I have Inventory table in my Parse database with two relevant fields: productId and quantity. When a shipment is received, a record is created containing the productId and quantity. Similarly, when a sale occurs, an inventory record is made with the productId and quantity (which will be negative, since the inventory will decrease after the sale). I would like to run a group by/ sum aggregate query on the Inventory table with Parse Cloud Code that outputs a dictionary containing unique