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 ?
(Sorry for my language) Thanks in advance
CodePudding user response:
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.
CodePudding user response:
this worked flawlessly
videos<-videos[!duplicated(sapply(videos, function(x)x$id))]
