thanks everyone. all solutions were better than what I had, and simple. R is an interesting experience. Extremely powerful and awe-inspiring for its elegance; things work like I would never have believed how elegantly they work. The IQ in the subsetting alone is superbly clever. And then it turns around: figuring out how to do simple things can take a long time---until I realize that it is somewhere somehow built in already. So, R (and the answers from helpful souls on this list) often makes me feel quite stupid. Yes, I first search; yes, I always look---but either I did not know or I had forgotten. I used to use perl for much work, and although there is much to like about it, R seems to be even better for most tasks---except that there is one perl resource that R cannot beat: the Perl Cookbook. if I only had an R cookbook... regards, /ivo --- ivo welch professor of finance and economics brown / nber / yale