R – Delete columns based on the value of a specific row

I have a table which contains a “Total” row that sums all previous rows for each column. I’d like to delete every column that has a total inferior to 10. In the following example, that would mean deleting column B and C.

ID Column A Column B Column C Column D
A 5 1 2 10
B 0 0 3 15
C 7 1 1 22
Total 12 2 6 47

I haven’t really tried anything because I am not familiar at all dealing with specific rows in R. Thank in advance for your help.

Leave a Comment