Consider the following table:
tab = Join[Partition[RandomReal[{0, 1}, 100], 1],
Partition[RandomInteger[{0, 1}, 100], 1], 2];
I would like to obtain the following. If more than 74 elements of the second column are equal to 1, then the list of 74 elements of the first column for which the second column == 1 (the order of elements does not matter). If there are less than 74 elements (say, this number is m
), then the joined list made of these m
elements + 74-m
elements that are equal to $\pi/2$.
Could you please tell me how to do this?