I have a large dataset with multiple instances of 'Player', and I want to collapse their tournament scores into a single row but keep the row with the highest earnings. It's a large data set so I can't exactly paste the whole thing but a small example table looks like this:
> table1 <- matrix(c('John Doe',2100,20,'N/A','N/A','John Doe',1000,'N/A',19,'N/A','John Doe',500,'N/A','N/A',5),ncol=5,byrow=TRUE) > colnames(table1) <- c("Player","Earned","Tournament1","Tournament2","Tournament3")
I'd like to eliminate the N/A values and the duplicate rows by combining Tournament 1, 2, 3 into a single row, and also keeping the highest earnings value (2100). So far I've used top_n(1, Earned) to keep the row with the highest earnings, but it only keeps the score of Tournament1, and I need to fill in the other columns with their scores.