My initial sample data was ambiguous so updating my data set
a <- data.table(name=c("?","","One","?","","Two"), value=c(1,3,2,6,5,2) , job=c(1,1,1,2,2,2) )
name value job
1: ? 1 1
2: 3 1
3: One 2 1
4: ? 6 2
5: 5 2
6: Two 2 2
I want to group by the column "job" while finding the maximum in column "value" and selecting the "name" which has the maximum length.
My sample output would be
name job value
1: One 1 3
2: Two 2 6
I think I want the equivalent of How do I select the longest 'string' from a table when grouping in R