The output for the new example should be: project v 1 0 2 0.5 3 1.5 4 0.5
The output you calculated was correct for the v per year, but the v per group would be incorrect. I think the problem lies in the fact that expand.grid(B,B) doesn't take into account that combinations of B can only be formed within A. Thanks again! -- View this message in context: http://r.789695.n4.nabble.com/Re-Transforming-relational-data-tp3307449p3319103.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.