If one has 4 judges and they each give a score for a particular performer or a particular topic then one could have 4 vectors with each containing the score.
But one would like to turn that into a rank to overcome grade inflation by one judge compared to another.
that is easy
transform(assignment,judge1.rank=rank(judge1),judge2.rank=rank(judge2),
judge3.rank=rank(judge3), judge4.rank=rank(judge4))
But then for each row (performer or topic) I want another four columns that for each row states the rank of ranks (or parallel rank) for each judge.
I would like to do something such as
prank(judge1.rank,judge2.rank,judge3.rank,judge4.rank)
I guess it would have to output as a dataframe.
I thought of using the reshape package to melt the data but that is just a preliminary thought.
If I understand you correctly, this will do what you want:
We compute the ranks for each judge using
sapply()which returns a matrix of ranks. Then we use applyrank()on the rows of this matrix to compute the performer/row ranks. A final transpose gets the result back in the required orientation.Wrap that in a function and you are good to go:
Which gives:
The
...allows arguments torank()to be passed in, for example theties.methodargument: