Delete Duplicate Rows Based On Column Values in R (Example) | Select Unique Row | Order Data Frame

Published: 05 May 2022
on channel: Statistics Globe
1,791
18

How to extract unique rows based on a logical condition in the R programming language. More details: https://statisticsglobe.com/delete-du...
R code of this video:

data <- data.frame(x = c("a", "a", "a", "a", "b", "b", "c"), # Create example data
y = c(3, 1, 4, 2, 1, 2, 1))
data # Print example data

data_default <- data[!duplicated(data$x), ] # Extract unique rows
data_default # Print data with unique rows

data_ordered <- data[order(data$y, decreasing = TRUE), ] # Order data
data_ordered # Print ordered data

data_highest <- data_ordered[!duplicated(data_ordered$x), ] # Unique rows of ordered data
data_highest # Print unique rows of ordered data

Follow me on Social Media:
Facebook – Statistics Globe Page:   / statisticsglobecom  
Facebook – Group for Discussions & Questions:   / statisticsglobe  
LinkedIn – Statistics Globe Page:   / statisticsglobe  
LinkedIn – Group for Discussions & Questions:   / 12555223  
Twitter:   / joachimschork  

Music by bensound.com