I understand the questions wording is not clear but its a simple one, hopefully the image will convey more than words. I need a new column (New Col in image) which gets a value from column B corresponding to max value in column N (by group) in this case A.
Preferably tidyverse solution since I am piping a long command.
df <- structure(list(A = c("a", "a", "a", "a", "a", "b", "b", "b"),
B = c("b", "c", "d", "e", "f", "c", "d", "e"), N = c(1L,
2L, 3L, 4L, 5L, 5L, 4L, 3L), New.Col = c("f", "f", "f", "f",
"f", "c", "c", "c")), class = "data.frame", row.names = c(NA,
-8L))
