#ok, finally this is my final "best and more compact" solution of the problem by merging different contributions (thanks to all indeed)
t<-data.frame(id=c(18,91,20,68,54,27,26,15,4,97),A=c(123,345,123,678,345,123,789,345,123,789)) l<-sapply(unique(t$A), function(x) t$id[which(t$A==x)]) r<-data.frame(unique_A= unique(t$A), list_id=unlist(lapply(l, paste, collapse = ", "))) r [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.