Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206260

Pivot Table in R, Summarizing Based on Most Frequently Appearing Value in Column of Character Values

$
0
0

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.


Viewing all articles
Browse latest Browse all 206260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>