동적 열 클래스를 기반으로 데이터 하위 집합에 대한 질문이 있습니다. 예 :동적 열의 데이터 집합 서브 세트
#Coming from other source. Dont exaclty know about their names and number of classes.
#But following are two demography, which will help in imagining the problem
gender <- c(1,2)
agegroup <- c(1,2,3,4,5,6,7,8)
#moredemo.................
# reproducible data
set.seed(1)
col1 <- as.data.frame(rep(gender, 100))
col2 <- as.data.frame(rep(agegroup, 25))
col3 <- runif(200)
datafile <- cbind(col1, col2, col3)
names(datafile)[1] = "gender"
names(datafile)[2] = "agegroup"
datafile <- as.data.frame(datafile)
#Subset is only for gender = 1 and agegroup = 3
#Subset is for every combination of classes in each demography
#No hardcoded name is required, because demography name will not be know
dat_gender_1_agegroup_3 <- datafile[datafile$gender == 1 & datafile$agegroup == 3, ]
그러나 성별 및 연령대가 아닌 인구 통계가 더 많을 수 있습니다. 소득이나 교육 또는 인종 등이있을 수 있습니다. 각 인구 통계학에는 다양한 수업이 있습니다. 다양한 수의 열에 데이터 집합 데이터 파일의 하위 집합을 가져 오는 것을 도와주세요. 콤보에 대한 그리드를 확장하여 사용
[MCVE] –