[R] aggregate and list elements of variables in data.frame

Massimo Bressan m@@@|mo@bre@@@n @end|ng |rom @rp@@veneto@|t
Thu Jun 7 15:48:38 CEST 2018

#ok, finally this is my final "best and more compact" solution of the problem by merging different contributions (thanks to all indeed) 

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 = ", "))) 

	[[alternative HTML version deleted]]

More information about the R-help mailing list