I have a long (approx. 4000 rows) list whose elements are in the form as follows:
{{x,y,z},a,b,c}
I want to count the number of elements c
in the last column that are greater than a certain number d
. How can I do it?
I have a long (approx. 4000 rows) list whose elements are in the form as follows:
{{x,y,z},a,b,c}
I want to count the number of elements c
in the last column that are greater than a certain number d
. How can I do it?
Suppose your long list is named data
, one approach can be
Select[data, Last[#] > d &] // Length
where d
should have a preset value.
Total@UnitStep[data[[All, -1]] - d]
? Of course,Count
is much nicer to read, but also much slower. To have something nice to read and fast, check out BoolEval (BoolCount
) $\endgroup$ – Szabolcs Sep 21 '18 at 14:29Count[ data, { __, c_ /; c > d}]
$\endgroup$ – Jason B. Sep 21 '18 at 14:32