I have a sample data.frame as shown below, I want to create another data.frame file that contains the statistics of this table with a specific column, how can I do this?
Like, for example, in data.frame below, I like to get the sum of each column in a chart.
Example data.frame:
Chart Sum Sum_Squares Count Average
Chart1 2 4 4 1
Chart1 3 9 3 1.5
Chart2 4 16 5 2
Chart2 5 25 2 2.5
Required Conclusion:
Chart Sum_sum Sum_square_sum Count_sum Average_sum
Chart1 5 13 7 2.5
Chart2 9 41 7 4.5
I tried the code below, but the return table contains only Chart and V1. sum_stat is data.frame
sum_stat = data.table(spc_point[,c("CHART", "SUM", "SUM_SQUARES", "COUNT", "AVERAGE")])[,c(SUM_SUM=sum(SUM), SUM_SQUARE_SUM=sum(SUM_SQUARES), COUNT_SUM=sum(COUNT), AVERAGE_SUM=sum(AVERAGE)),by=list(CHART)]
thanks in advance
source
share