How can I count the number of grouped pairs in which one row's column value is greater than another?
问题 I have a dataset (df1) with a number of paired values. One row of the pair is for one year (e.g., 2014), the other for a different year (e.g., 2013). For each pair is a value in the column G. I need a count of the number of pairs in which the G value for the higher year is less than the G value for the lesser year. Here is my dput for the dataset df1: structure(list(Name = c("A.J. Ellis", "A.J. Ellis", "A.J. Pierzynski", "A.J. Pierzynski", "Aaron Boone", "Adam Kennedy", "Adam Melhuse",