'Remove Duplicates in Nested List in R using Key Element

I have a nested list videos inside this list there is key element "id" I want to remove all the duplicate videos from this nested list using the "id". Can some good soul help me in solving this ?

Here is the Nested List in R



Solution 1:[1]

id_list = c()
dups = c()
videos1 = list()
for(i in 1:545){
  if (videos[[i]][[1]] %in% id_list){
    dups = append(videos[[i]][[1]], dups)
  }else{
    id_list = append(videos[[i]][[1]], id_list)
    videos1 = append(videos[[i]], videos1)
  }
}
  
  

Can you try this.Videos1 list will give you the list of unique video lists.

Solution 2:[2]

The following worked flawlessly:

videos<-videos[!duplicated(sapply(videos, function(x)x$id))]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yagami_Light
Solution 2 Bertold Kolics