# Removing an ordered pair from a list of ordered pairs if the second element in the list is Less than a Value

I have a list of ordered pairs from a piezoelectric sensor sampled at 2kH. The first element is time and the second, amplitude. I'm trying to remove all ordered pairs in the list of ordered pairs when the amplitude is less than 20mV.

I've been working with the Select Function

 data4cutoff = Select[data4[[All, 2]], # > 20 &]


but this only returns a list of amplitudes. Is there a way to keep the ordered pairs with amplitudes over 20?

-
try Select[data4, #[[2]] > 20 &] – kglr Nov 29 '12 at 5:27
You should make that the answer so it can be accepted – Gabriel Nov 29 '12 at 5:30
Please see the editing help page for type-setting help ... and welcome to Mma.SE. – kglr Nov 29 '12 at 5:34
Thanks so much kguler. It worked – user1861149 Nov 29 '12 at 5:34

You have several alternatives to select the rows that satisfy the condition:

data = RandomReal[{0, 50}, {10, 2}]
(* {{46.6745, 22.4118}, {3.45111, 44.7088}, {23.3653, 39.9679},
{14.3158, 17.5128}, {28.1736, 17.5333}, {49.1356, 30.1345},
{22.2756, 2.92285}, {26.3554, 37.4685}, {32.4265, 21.1889},
{45.3501, 38.5635}} *)


sel1 = Select[data, #[[2]] > 20 &];


you can also use

sel2 = Cases[data, {_, _?(# > 20 &)}];
sel3 = DeleteCases[data, {_, _?(# <= 20 &)}];
sel4 = Pick[data, #[[2]] > 20 & /@ data];
sel5 = Pick[data, # > 20 & /@ data[[All, 2]]];
sel6 = data /. {{x_, y_} /; (y > 20) :> {x, y}, {_, _} :> Sequence[]};
sel7 = data /. {_, y_} /; (y <= 20) :> Sequence[]
(* {{46.67449041915749,22.411774029202064}, {3.451110536527459,44.708769225023616},
{23.365342865421695,39.96791941543168}, {49.13560113208372,30.134498577575656},
{26.355391411430162,37.46849312606298}, {32.42652381672336,21.188851959547975},
{45.350061059853985,38.56354675834069}} *)
sel1 == sel2 == sel3 == sel4 == sel5== sel6== sel7
(* True *)

-