I am trying to calculate the column sums, then select the top 2. This is a sample of the data frame:
df <- data.frame(precinct = c("A", "B", "C"),
steve = c(309, 337, 294),
mike = c(120, 151, 240),
allan = c(379, 442, 597))
I know how to use colSums
to get the column totals.
dfColTot <- colSums(df[ , 2:ncol(df)])
From there, how do you select the top 2 sums and names?