I have data like this:
ID SHape Length
180139746001000 2
180139746001000 1
I want to delete the duplicate rows whichever has the less shape length. Can anyone help me with this?
I have data like this:
ID SHape Length
180139746001000 2
180139746001000 1
I want to delete the duplicate rows whichever has the less shape length. Can anyone help me with this?
with
df <- data.table(matrix(c(102:106,106:104,1:3,1:3,5:6),nrow = 8))
colnames(df) <- c("ID","Shape Length")
just use duplicated
after sorting
setkey(df,"V2")
df[!duplicated(V1, fromLast = TRUE)]
You can select the highest shape length for each ID by performing
df %>%
group_by(ID) %>%
arrange(SHape.Length) %>%
slice(1) %>%
ungroup()