title: How do I select the 'flat' parts of a line?
body: <p>I need to process a series of curves like the one show below. What I want to do is to select the parts of the curve that are "flat", i.e. the colored parts (ignore the different colors). I can of course do it manually, as I did for this figure, but it is a long a tedious task. I could not find a function or package that can do that - mostly because I am not sure how to call this type of analysis. Can somebody point me in the right direction? </p>
  
  <p><img src="https://i.stack.imgur.com/thsJg.png" alt="example plot"></p>
  
  <pre><code>x &lt;- c(2891.772,7143.258,13610.388,25692.848,48727.260,79326.336,96609.834,92664.960,76867.428,61821.760,51122.910,43083.040,39840.163,37286.424,34921.704,33515.898,32583.036,31997.868,32203.850,31092.060,30280.570,29822.526,29493.870,29405.694,29603.545,28848.582,29283.450,29159.202,29420.724,28916.718,29088.060,28846.578,28878.642,28310.508,28798.560,28685.256,28422.732,28134.156,28373.634,28355.813,28496.880,27905.700,28116.447,28293.627,9116.107,6371.718,4539.060,3203.200,1992.978,1320.636,861.992,638.911,478.956,313.626,231.231,151.302,106.318,98.392,65.130,49.098,38.076,40.080,36.072,28.056,37.074,28.224,42.084,38.114,25.050,24.048,33.066,35.070,26.052,26.052,16.160,24.048,23.069,17.034,31.093,22.044,19.038,21.042,27.081,25.050,23.023,20.040,19.019,21.063,32.064,21.042,20.060,21.042,21.042,25.200,21.021,17.051,18.036,19.038,26.052,25.050,4.048,25.050,25.050,13.026,25.050,22.044,20.040,19.038,19.038,17.017,30.060,17.017,18.036,20.040,24.048,16.032,15.015,18.036,16.016,10.020,14.028,16.032,16.128,24.048,19.038,20.040,17.017,12.024,17.034,19.057,16.032,12.024,15.045,16.032,27.054,15.030,320.640,5997.972,24837.289,61030.818,104415.311,125609.718,117072.678,91065.379,65335.410,47371.554,36088.032,29700.836,25411.005,23390.688,21863.984,20463.443,20130.180,19619.160,19304.741,18867.660,18280.488,18246.576,18151.230,18051.030,18097.122,17686.302,17769.468,17500.483,17615.689,17409.750,17171.274,17369.670,17222.376,17640.210,17519.401,17291.514,17452.200,17566.549,17579.088,18287.699,17627.725,17835.600,17848.626,17774.163,18295.518,18281.490,18242.224,20795.508,33304.615,47859.528,68305.338,77375.442,77291.274,73746.900,70728.174,70676.395,69709.640,69602.928,69859.953,69732.663,71487.690,71840.800,70562.492,72048.810,70596.912,71397.510,72172.871,70747.677,71460.636,71211.060,71017.752,71285.286,72170.052,72483.678,72126.966,71505.726,72755.220,72148.008,54343.731,42154.140,33928.481,28074.036,21933.780,16357.650,12583.116,10036.032,8659.284,8279.526,8248.464,8999.964,9923.808,11421.161,12934.818,14374.360,15590.118,16705.689,18170.072,19323.570,20167.147,21160.236,21244.404,22014.942,22510.932,22795.500,23483.874,23582.559,23494.471,24271.446,24106.116,24194.170,24452.808,24526.956,24093.090,24822.546,24805.512,25136.172,25008.802,25417.023,24888.864,25402.704,24886.436,24721.344,24470.844,24631.164,24726.354,24606.114,24826.802,24969.840,24717.336,24412.728,24395.969,24439.415,24711.324,44541.906,65939.616,126498.360,224679.462,258782.532,214498.140,160828.014,123817.140,104069.724,94299.051,88682.010,84510.684,83337.306,82116.613,81277.230,81206.088,80375.430,80781.620,79833.348,81957.034,81954.582,83004.678,83084.001,82011.696,80649.978,80587.854,80514.708,79381.446,80502.422,80047.000,81602.074,80374.402,81839.352,80076.511,79584.852,79633.185,78967.620,78584.506,43499.826,31657.188,22512.335,16062.042,11563.080,7580.674,4479.942,2414.820,1388.772,729.456,447.447,306.612,208.416,142.284,160.320,121.121,126.252,119.238,83.166,91.182,75.150,78.156,76.152,82.246)
  </code></pre>