R create unique combinations of IDs in a given class (all combinations not getting created)
问题 Hi I have a dataset like the following: library(gtools) z=c(120,122,124,126) ID=as.character(c(1,2,3,4,5,6,7,8,9,10,11,12)) IQ=c(120.5,123,125,122.5,122.1,121.7,123.2,123.7,120.7,122.3,120.1,122) Section=c("A","A","B","B","A","B","B","A","B","A","B","B") zz=data.frame(ID,IQ,Section) I am trying to create unique combinations of the IDs if the ID's lie in the given classes: 120-122, 122-124 and 124-126. combin_list=list("list",length(z)) Initial_IQ=0 jj=1 for (IQ1 in z){ obs_list=zz[(zz$IQ<IQ1