Is there an obvious reason why this won't loop to i=2 and beyond? There are many combinations of *st* & *vc* that don't exist in svc. For example, when s=1 there's only an entry at v=1. That's fine, the entry can stay 0.
lookup.svc <- array(0,dim=c(length(unique(svc$st)),length(unique(svc$vc))), dimnames=list(unique(svc$st), unique(svc$vc))) for (i in 1:length(unique(svc$st))) { for (j in 1:length(unique(svc$vc))){ lookup.svc[i,j] <- svc[svc$st == unique(svc$st)[i] & svc$vc == unique(svc$vc)[j], 4] }} Thanks, Robin ~~~~~~~~~~~~~~~~~~~ -Robin Jeffries Dr.P.H. Candidate UCLA School of Public Health rjeffr...@ucla.edu 530-624-0428 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.