我想运行这个循环:
householdnums=numeric()
for(i in 1:length(households)){
hh = households[i]
householdnums = c(householdnums,which(hhlist==hh))
}
家庭和hhlist是一个大型载体。问题是家庭在hhlist中有重复的元素,我需要保留排序。例如。
hhlist = c(1,2,3,4,5,6, 8)
households = c(1,2,1,1,4,5,6,8)
householdnums should be:
householdnums
[1] 1 2 1 1 4 6 6 7
答案 0 :(得分:0)
匹配:例如匹配(家庭,hhlist)