On 2/06/2009 10:17 AM, Vincent Arel wrote: > Your python-like example is also quite helpful.
It is not "python-like". Apart from the "..." in the initial data "vectors", it is executable Python code. > As I understand it, you > basically implement Igor's suggestion of running loops on the vectors. More or less :-) BTW, I miscoded; see below. > I > should be able to do that quite easily. Most importantly though, it appears > that I need to revise my understanding of the division of labour between > sqlite and R. > > Thanks a lot for your help, and have a great week! You're welcome ... you too. [big snip] >> >> var1 = ["ALB", "CAN", "DZA", ...] >> var2 = ["ALB", "CAN", "DZA", ...] >> var3 = ["1961", "1962", "1963",...] >> # get a list of unique country codes, in sorted order >> countries = list(set(var1 + var2)) >> countries.sort() >> # convert years to integer, find range >> var3int = [int(y) for y in var3] >> firsty = min(var3int) >> lasty = max(var3int) >> year_range = range(firsty, lasty + 1) >> # do the business >> id = 0 following works very hard to throw away half of your results :-( >> ncountries = len(countries) >> for i in range(ncountries - 1): >> for j in range(i + 1, ncountries): >> assert countries[i] != countries[j] >> id += 1 >> for year in year_range: >> print id, countries[i], countries[j], year should be: for c1 in countries: for c2 in countries: if c2 == c1: continue id += 1 for year in year_range: print id, c1, c2, year and sorting the countries is not essential, but maybe helpful when visually checking the output. Cheers, John _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users