3
votes

I have imported some data into Mathematica. The data will look similar to

{{0,2},{2,3},{4,3},{5,4},{8,4}}

I want to throw out all elements for which the x-values are smaller than a given value or create a new list that contains the data for which the x-values are larger than this value. I assume that Select should do the job but I don't know how.

Thanks in advance for the help.

2

2 Answers

5
votes

How about

 data = {{0,2},{2,3},{4,3},{5,4},{8,4}};
 filtered = Select[data, First[#]>3&];

where you replace 3 with your given value?

3
votes

Another versatile approach is to use Cases and attach a condition (/;)

For example:

data = {{0, 2}, {2, 3}, {4, 3}, {5, 4}, {8, 4}}; Cases[data, {x_, y_} /; x > 3]

or attach a condition as follows (for example):

Cases[data, {x_ /; x > 3, _}]

(The approach will also work with DeleteCases)