In the table below, how can I find the two highest values in each row, then add these values together?
I have a copy of the attached table in RStudio. Is there a line of code I can use to add the two highest numbers on each row, so that I can apply to this to a much bigger dataset?
You can do a rowwise calculation where you sort the values in the specified columns and sum the highest two:
If you don't want to specify the column names manually you can also select all numeric columns at once:
Both strategies give the result: