I'm trying to replicate the max if function from Excel in R.
ksu price max
9144037 3.11 3.11
8448749 4.19 5.24
9649391 0 8.39
8448749 4.19 5.24
8448749 4.19 5.24
8448749 4.19 5.24
8448749 4.19 5.24
9649391 8.39 8.39
8448749 5.24 5.24
9144037 1.99 3.11
9144037 1.99 3.11
If I were doing it in excel i'd use max(if()). This code is supposed to look at the max price for each ksu, and return the max value on the last column. I've tried this :
max(price[ksu == ksu])
But it doesn't give me the desired output. It only returns one max value regardless of the ksu.