[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) 
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]]
    
    
More information about the R-help
mailing list