R aggregate data.frame with date column

前端 未结 4 1133
挽巷
挽巷 2020-12-18 13:33

I have the data frame resambling the one in the below

Date       Expenditure Indicator
29-01-2011 5455        212
25-01-2012 5452        111
11-02-2011 365           


        
4条回答
  •  醉酒成梦
    2020-12-18 14:09

    df <- data.frame(c('29-01-2011', '25-01-2012', '11-02-2011'), c(5455, 5452, 365), c(212, 211, 5))
    colnames(df) <- c('Date', 'Expenditure', 'Indicator')
    colSums(df[2])
    
    #>Expenditure 
    #11272 
    

提交回复
热议问题