I am working with a database of all transit systems in America and trying to compare different agencies. Each case is a specific part of an organization. For example, bus lines are separate from subways. I would like to combine the values for all of the cases for a given agency.
Basically I want to sum the value of each column for each "Trs_Id" and delete the rest. This data frame is the breakdown of operating expenses ("opex"). Here is what my dataset looks like in R:
> colnames(opex)
[1] "Trs_Id" "Mode_Cd"
[3] "Service_Cd" "Expense_Category_Desc"
[5] "Op_Sal_Wage_Amt" "Other_Sal_Wage_Amt"
[7] "Fringe_Benefit_Amt" "Service_Costs_Amt"
[9] "Fuel_Lubricant_Amt" "Tire_Tube_Amt"
[11] "Other_Mat_Sup_Amt" "Utility_Amt"
[13] "Casuality_Liability_Amt" "Tax_Amt"
[15] "In_Report_Amt" "Sep_Report_Amt"
[17] "Misc_Expense_Amt" "Expense_Transfer_Amt"
[19] "Ada_Related_Amt"
> NROW(opex)
[1] 6956
> id_nm <- table(opex$Trs_Id)
> NROW(id_nm)
[1] 616