I have a dataset and would like to select only the smallest value between each primary key. Here is the example of my DF:
ORDEM <- c(1,5,2,3,1,10)
GUIA <- c('111','111','333','333','555','555')
COR <- c('AZUL','AMARELO','PRETO','LARANJA','ROSA','VERDE')
DADOS <- data.frame(ORDEM,GUIA,COR)
In this example, there are two records for each key ( GUIA
). Therefore, I would like the result to show only the smallest value from the ORDEM
column. The result I hope should be:
ORDEM <- c(1,2,1)
GUIA <- c('111','333','555')
COR <- c('AZUL','PRETO','ROSA')
DADOS_FINAL <- data.frame(ORDEM,GUIA,COR)