I have the following dataset:
df =
A B C D
1 4 0 8
0 6 0 9
0 5 0 6
1 2 0 9
I want to obtain a vector with the names of the two columns with the highest colSum:
"B" "D"
So far I have tried:
List_names_TOP2 <- str(sort(colSums(df),
decreasing = TRUE)[1:2])
but I get an error. Any recommendation?