Solution :
I have read your problem, I can understand that you are learning the new technology so you are experiencing the errors while executing your code.
I think the problem is that your list may be containing only one element. And your call to sort()
is now trying to sort the list and not the single element.
I can suggest you two simple solutions:
To sort your values in a element of your list, you can use
head(sort(var_sal[[1]], decreasing=TRUE), 3)
Here a [[1]] is selecting the very first element of your list and then sorting your values within it.
Or you can create var_sal explicitly as the numeric vector instead:
var_sal <- (irs_data[13]/irs_data[12])[[1]]