I am attempting to create a pivot table in R.
I have code like so:
Grps <- c("MoveNumber","TripOrderNumber","BillToParentAssignment","AccountOwner","MonthYear", + "Shipper_Latitude","Shipper_Longitude","Shipper.CompanyAddress", + "ShipCity_New","ShipperState","ShipperZip","ShipCntry1","ShipCntry2", + "Consignee_Latitude","Consignee_Longitude","Consignee.CompanyAddress", + "ConsCity_New","ConsigneeState","ConsigneeZip","ConsCntry1","ConsCntry2", + "InvoiceCurrency","CommodityDesc","One.TrailerAxles","Two.TrailerAxles","Trailer_tsID", + "TariffNumber","DateBilled","IndexEndDate")
Start2 <- Start2 %>% group_by_at(Grps) %>% + summarise( + TM = sum(Travel.Miles), + LM = sum(LoadedMiles), + EM = sum(EmptyMiles), + LH = sum(LinehaulRev), + FSC = sum(FuelRev), + Terminal = mode(Terminal), + AccessRev = sum(AccessorialRev), + StopCount = sum(StopCount), + Pickups = sum(Pickups), + Deliveries = sum(Delivery) + )
The pivot works fine except for Terminal. What I am looking for is the most frequently appearing value in a column of characters. Instead, I get "character" in every row.
Would be grateful for a solution.