DATA1 = data.frame("ID" = c("f","e","b","a","e","d","e","f","c","d","d","c","d","b","e","b","d","b","e","e","b","a","b","e","a","d","a","d","b","f","b","e","b","d","e","d","b","e","f","a","b","b","f","e","c","a","b","d","c","d","e","e","f","e","a","b","b","c","b","a","b","f","a","b","c","e","d","a","e","d","a","f","b","d","e","b","f","e","f","f","c","b","f","c","b","e","e","f","e","b","f","f","b","e","c","a","e","c","d","b"),
"CLASS" = c(4,1,2,4,1,4,3,2,1,1,2,4,2,2,3,1,4,1,2,4,2,2,1,1,1,3,4,4,4,3,3,2,3,2,2,2,3,4,1,2,4,1,1,3,3,2,2,2,4,4,3,3,1,1,4,2,3,2,4,1,4,3,2,3,4,3,3,2,3,4,4,1,4,1,2,3,4,1,2,1,3,4,4,3,1,2,4,2,3,2,4,2,2,1,1,4,1,3,1,1),
"SCORE" = c(59,65,61,64,91,91,70,90,64,87,51,54,92,76,75,78,55,99,66,57,88,89,77,66,100,92,80,84,52,66,59,71,56,88,51,97,65,89,65,67,52,57,51,63,67,79,51,90,79,54,90,55,90,72,64,52,95,61,87,54,91,75,80,93,53,81,87,85,84,84,81,93,100,51,70,64,51,54,83,96,65,61,53,80,68,73,52,57,96,55,63,97,94,77,63,98,85,97,65,77))
DATA2 = data.frame("CLASS" = c(1,2,3,4),
"S" = c(2,5,3,1))
У меня есть набор данных 'data1' и 'data2'.
Я хочу go в 'data1' и foreach 'id' в 'data1' Я хочу t ":
RANDOM SAMPLE 'S' ROWS FOR EACH 'CLASS' WHERE VALUE FOR 'S' IS GOTTEN FROM 'DATA2'.
Например, затем - в классе 'data2' = 2, s = 5. поэтому для каждого 'id' в 'data1' я хочу выбрать случайную выборку из 5 строк, где class = 2