accelerating code execution in R to provide counting of all possible combinations of events belonging to certain ID
问题 I have a data set that has 3 columns , (ID , D , AE). sample=data.frame( ID=c(1,1,1,2,2,2), D=c('a','b','c','a','c','c'), AE=c('m','x','w','y','m','f') ) I want to count the number of IDs where all possible combinations that consist of any combination between any two drugs within a certain ID and the AEs corresponding to that ID. please see the image to understand exactly what i mean enter image description here. Someone could help me with a code that worked perfectly on the small dataset