Dear helpers, I'm using R version 2.8.0.
Suppose that I have a small data set like below. [,1] [,2] [,3] [,4] a 1 1 0 0 b 0 1 1 0 c 1 1 1 0 d 0 1 1 1 First, I'd like to find sum of each row uniquely present in each row, but only sequentially from the top row, meaning that if the value appears in the following column(s), that shouldn't enter the sum. The result should be like this: row.sum [1] 2 1 0 1 And if a and c were swapped, the row.sum is row.sum [1] 3 0 0 1 Second, I'd like to randomly reorder the rows, and repeat calculating row.sum again, for many times less than all combinations possible (4! In this case), kind of simulation, and store the results into a matrix. Thanks. Keun-Hyung [[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.