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?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communitySuppose 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$Count[ data, { __, c_ /; c > d}]
$\endgroup$