[R] aggregate and list elements of variables in data.frame
m@@@imo@bre@@@n @ending from @rp@@veneto@it
Wed Jun 6 10:13:10 CEST 2018
#given the following reproducible and simplified example
#I need to get the following result
r<-data.frame(unique_A=c(123, 345, 678, 789),list_id=c('1,3,6,9','2,5,8','4','7,10'))
# i.e. aggregate over the variable "A" and list all elements of the variable "id" satisfying the criteria of having the same corrisponding value of "A"
#any help for that?
#so far I've just managed to "aggregate" and "count", like:
sqldf('select count(*) as count_id, A as unique_A from t group by A')
t%>%group_by(unique_A=A) %>% summarise(count_id = n())
# thank you
[[alternative HTML version deleted]]
More information about the R-help