Delete elements less than the last largest elementDeleting multiple elements from a listChanging the precision of data in a list of matricesJoin nested lists based on first and last elements within each listUsing Select function to select elements based on last element of nested listDelete only when there are two (or more) 1smaking two columns from 1D-horizontal dataDelete some elements based on the keysHow to set a particular element of a list to a number?delete an element list recursivelyElegant way of partitioning in two starting from the second element?

How should I ask for a "pint" in countries that use metric?

Why did Old English lose both thorn and eth?

Did depressed people far more accurately estimate how many monsters they killed in a video game?

stuck in/at beta

How does one acquire an undead eyeball encased in a gem?

Blocks from @ jafe

Why do people prefer metropolitan areas, considering monsters and villains?

Compute Manhattan distance from origin given a set of left-right-step directions

Computer name naming convention for security

Deck of Cards with Shuffle and Sort functionality

Is "wissen" the only verb in German to have an irregular present tense?

Why am I getting unevenly-spread results when using $RANDOM?

With a data transfer of 50 GB estimated 5 hours, are USB-C claimed speeds inaccurate or to blame?

What is the relationship between external and internal composition in a cartesian closed category?

Why does Trump want a citizenship question on the census?

Delete elements less than the last largest element

Tikz people in diagram

Is it ok for parents to kiss and romance with each other while their 2- to 8-year-old child watches?

Who goes first? Person disembarking bus or the bicycle?

Sense of humor in your sci-fi stories

Category-theoretic treatment of diffs, patches and merging?

Test Driven Development Roman Numerals php

Why won't the U.S. sign a peace treaty with North Korea?

How do resistors generate different heat if we make the current fixed and changed the voltage and resistance? Notice the flow of charge is constant



Delete elements less than the last largest element


Deleting multiple elements from a listChanging the precision of data in a list of matricesJoin nested lists based on first and last elements within each listUsing Select function to select elements based on last element of nested listDelete only when there are two (or more) 1smaking two columns from 1D-horizontal dataDelete some elements based on the keysHow to set a particular element of a list to a number?delete an element list recursivelyElegant way of partitioning in two starting from the second element?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3












$begingroup$


Here is my list. The first column contains its index and second column has data.



list=1, 170.93, 2, 170.4, 3, 174.08, 4, 160.65, 5, 166.44, 6, 
169.75, 7, 175.86, 8, 177.6, 9, 180.27, 10, 182.82, 11,
182.02, 12, 186.65, 13, 184.53, 14, 186.17, 15,
177.29, 16, 172.06, 17, 175.58, 18, 168.09, 19,
172.33, 20, 165.1, 21, 154.88, 22, 161.28, 23, 165.25, 24,
165.15, 25, 171.03, 26, 174.55, 27, 182.57, 28,
191.02, 29, 191.11, 30, 184.93, 31, 188.85, 32, 191.44;


I want to delete all numbers that are smaller than the last largest element. For example, I want to delete 4th, 5th and 6th elements because they are smaller than the last largest element (3rd). Similarly, I want to delete elements from 13th to 27th elements because they are smaller than the last largest element (12th). 30th and 31st elements should be deleted because they are smaller than prior largest element (29th). Final results should contain increasing numbers. Here is the tabular representation of the data:



enter image description here



I did my best to explain my problem. Please write in the comment if it is not clear. I have a big data and I need to manipulate it as explained here. Any help would be greatly appreciated. Thanks










share|improve this question









$endgroup$







  • 4




    $begingroup$
    DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
    $endgroup$
    – ciao
    7 hours ago










  • $begingroup$
    Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
    $endgroup$
    – Mark R
    7 hours ago











  • $begingroup$
    @ Mark R, yes you are right. I missed it. Thanks
    $endgroup$
    – DestinationLess_Traveller
    7 hours ago






  • 2




    $begingroup$
    DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
    $endgroup$
    – Bob Hanlon
    7 hours ago










  • $begingroup$
    @ Bob, thanks for your simple answer. I really appreciate it.
    $endgroup$
    – DestinationLess_Traveller
    2 hours ago

















3












$begingroup$


Here is my list. The first column contains its index and second column has data.



list=1, 170.93, 2, 170.4, 3, 174.08, 4, 160.65, 5, 166.44, 6, 
169.75, 7, 175.86, 8, 177.6, 9, 180.27, 10, 182.82, 11,
182.02, 12, 186.65, 13, 184.53, 14, 186.17, 15,
177.29, 16, 172.06, 17, 175.58, 18, 168.09, 19,
172.33, 20, 165.1, 21, 154.88, 22, 161.28, 23, 165.25, 24,
165.15, 25, 171.03, 26, 174.55, 27, 182.57, 28,
191.02, 29, 191.11, 30, 184.93, 31, 188.85, 32, 191.44;


I want to delete all numbers that are smaller than the last largest element. For example, I want to delete 4th, 5th and 6th elements because they are smaller than the last largest element (3rd). Similarly, I want to delete elements from 13th to 27th elements because they are smaller than the last largest element (12th). 30th and 31st elements should be deleted because they are smaller than prior largest element (29th). Final results should contain increasing numbers. Here is the tabular representation of the data:



enter image description here



I did my best to explain my problem. Please write in the comment if it is not clear. I have a big data and I need to manipulate it as explained here. Any help would be greatly appreciated. Thanks










share|improve this question









$endgroup$







  • 4




    $begingroup$
    DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
    $endgroup$
    – ciao
    7 hours ago










  • $begingroup$
    Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
    $endgroup$
    – Mark R
    7 hours ago











  • $begingroup$
    @ Mark R, yes you are right. I missed it. Thanks
    $endgroup$
    – DestinationLess_Traveller
    7 hours ago






  • 2




    $begingroup$
    DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
    $endgroup$
    – Bob Hanlon
    7 hours ago










  • $begingroup$
    @ Bob, thanks for your simple answer. I really appreciate it.
    $endgroup$
    – DestinationLess_Traveller
    2 hours ago













3












3








3





$begingroup$


Here is my list. The first column contains its index and second column has data.



list=1, 170.93, 2, 170.4, 3, 174.08, 4, 160.65, 5, 166.44, 6, 
169.75, 7, 175.86, 8, 177.6, 9, 180.27, 10, 182.82, 11,
182.02, 12, 186.65, 13, 184.53, 14, 186.17, 15,
177.29, 16, 172.06, 17, 175.58, 18, 168.09, 19,
172.33, 20, 165.1, 21, 154.88, 22, 161.28, 23, 165.25, 24,
165.15, 25, 171.03, 26, 174.55, 27, 182.57, 28,
191.02, 29, 191.11, 30, 184.93, 31, 188.85, 32, 191.44;


I want to delete all numbers that are smaller than the last largest element. For example, I want to delete 4th, 5th and 6th elements because they are smaller than the last largest element (3rd). Similarly, I want to delete elements from 13th to 27th elements because they are smaller than the last largest element (12th). 30th and 31st elements should be deleted because they are smaller than prior largest element (29th). Final results should contain increasing numbers. Here is the tabular representation of the data:



enter image description here



I did my best to explain my problem. Please write in the comment if it is not clear. I have a big data and I need to manipulate it as explained here. Any help would be greatly appreciated. Thanks










share|improve this question









$endgroup$




Here is my list. The first column contains its index and second column has data.



list=1, 170.93, 2, 170.4, 3, 174.08, 4, 160.65, 5, 166.44, 6, 
169.75, 7, 175.86, 8, 177.6, 9, 180.27, 10, 182.82, 11,
182.02, 12, 186.65, 13, 184.53, 14, 186.17, 15,
177.29, 16, 172.06, 17, 175.58, 18, 168.09, 19,
172.33, 20, 165.1, 21, 154.88, 22, 161.28, 23, 165.25, 24,
165.15, 25, 171.03, 26, 174.55, 27, 182.57, 28,
191.02, 29, 191.11, 30, 184.93, 31, 188.85, 32, 191.44;


I want to delete all numbers that are smaller than the last largest element. For example, I want to delete 4th, 5th and 6th elements because they are smaller than the last largest element (3rd). Similarly, I want to delete elements from 13th to 27th elements because they are smaller than the last largest element (12th). 30th and 31st elements should be deleted because they are smaller than prior largest element (29th). Final results should contain increasing numbers. Here is the tabular representation of the data:



enter image description here



I did my best to explain my problem. Please write in the comment if it is not clear. I have a big data and I need to manipulate it as explained here. Any help would be greatly appreciated. Thanks







list-manipulation programming






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









DestinationLess_TravellerDestinationLess_Traveller

1295 bronze badges




1295 bronze badges







  • 4




    $begingroup$
    DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
    $endgroup$
    – ciao
    7 hours ago










  • $begingroup$
    Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
    $endgroup$
    – Mark R
    7 hours ago











  • $begingroup$
    @ Mark R, yes you are right. I missed it. Thanks
    $endgroup$
    – DestinationLess_Traveller
    7 hours ago






  • 2




    $begingroup$
    DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
    $endgroup$
    – Bob Hanlon
    7 hours ago










  • $begingroup$
    @ Bob, thanks for your simple answer. I really appreciate it.
    $endgroup$
    – DestinationLess_Traveller
    2 hours ago












  • 4




    $begingroup$
    DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
    $endgroup$
    – ciao
    7 hours ago










  • $begingroup$
    Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
    $endgroup$
    – Mark R
    7 hours ago











  • $begingroup$
    @ Mark R, yes you are right. I missed it. Thanks
    $endgroup$
    – DestinationLess_Traveller
    7 hours ago






  • 2




    $begingroup$
    DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
    $endgroup$
    – Bob Hanlon
    7 hours ago










  • $begingroup$
    @ Bob, thanks for your simple answer. I really appreciate it.
    $endgroup$
    – DestinationLess_Traveller
    2 hours ago







4




4




$begingroup$
DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
$endgroup$
– ciao
7 hours ago




$begingroup$
DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
$endgroup$
– ciao
7 hours ago












$begingroup$
Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
$endgroup$
– Mark R
7 hours ago





$begingroup$
Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
$endgroup$
– Mark R
7 hours ago













$begingroup$
@ Mark R, yes you are right. I missed it. Thanks
$endgroup$
– DestinationLess_Traveller
7 hours ago




$begingroup$
@ Mark R, yes you are right. I missed it. Thanks
$endgroup$
– DestinationLess_Traveller
7 hours ago




2




2




$begingroup$
DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
$endgroup$
– Bob Hanlon
7 hours ago




$begingroup$
DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
$endgroup$
– Bob Hanlon
7 hours ago












$begingroup$
@ Bob, thanks for your simple answer. I really appreciate it.
$endgroup$
– DestinationLess_Traveller
2 hours ago




$begingroup$
@ Bob, thanks for your simple answer. I really appreciate it.
$endgroup$
– DestinationLess_Traveller
2 hours ago










1 Answer
1






active

oldest

votes


















4












$begingroup$

TakeList[list, Length /@ Split[FoldList[Max, list[[All, 2]]]]][[All, 1]]



1, 170.93, 3, 174.08, 7, 175.86, 8, 177.6, 9, 180.27, 10,
182.82, 12, 186.65, 28, 191.02, 29, 191.11, 32, 191.44




Also



max = list[[1, -1]];
Split[list, Or[Last[#2] < max, max = Last[#2]] &][[All, 1]]



same result




DeleteDuplicates[Join @@ FoldList[MaximalBy[Last] @* Append, First @ list, 
Rest @ list]]



same result




The first method is much faster.






share|improve this answer











$endgroup$












  • $begingroup$
    Thank you kglr.
    $endgroup$
    – DestinationLess_Traveller
    6 hours ago










  • $begingroup$
    @DestinationLess_Traveller, thank you for the accept.
    $endgroup$
    – kglr
    6 hours ago













Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f201662%2fdelete-elements-less-than-the-last-largest-element%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4












$begingroup$

TakeList[list, Length /@ Split[FoldList[Max, list[[All, 2]]]]][[All, 1]]



1, 170.93, 3, 174.08, 7, 175.86, 8, 177.6, 9, 180.27, 10,
182.82, 12, 186.65, 28, 191.02, 29, 191.11, 32, 191.44




Also



max = list[[1, -1]];
Split[list, Or[Last[#2] < max, max = Last[#2]] &][[All, 1]]



same result




DeleteDuplicates[Join @@ FoldList[MaximalBy[Last] @* Append, First @ list, 
Rest @ list]]



same result




The first method is much faster.






share|improve this answer











$endgroup$












  • $begingroup$
    Thank you kglr.
    $endgroup$
    – DestinationLess_Traveller
    6 hours ago










  • $begingroup$
    @DestinationLess_Traveller, thank you for the accept.
    $endgroup$
    – kglr
    6 hours ago















4












$begingroup$

TakeList[list, Length /@ Split[FoldList[Max, list[[All, 2]]]]][[All, 1]]



1, 170.93, 3, 174.08, 7, 175.86, 8, 177.6, 9, 180.27, 10,
182.82, 12, 186.65, 28, 191.02, 29, 191.11, 32, 191.44




Also



max = list[[1, -1]];
Split[list, Or[Last[#2] < max, max = Last[#2]] &][[All, 1]]



same result




DeleteDuplicates[Join @@ FoldList[MaximalBy[Last] @* Append, First @ list, 
Rest @ list]]



same result




The first method is much faster.






share|improve this answer











$endgroup$












  • $begingroup$
    Thank you kglr.
    $endgroup$
    – DestinationLess_Traveller
    6 hours ago










  • $begingroup$
    @DestinationLess_Traveller, thank you for the accept.
    $endgroup$
    – kglr
    6 hours ago













4












4








4





$begingroup$

TakeList[list, Length /@ Split[FoldList[Max, list[[All, 2]]]]][[All, 1]]



1, 170.93, 3, 174.08, 7, 175.86, 8, 177.6, 9, 180.27, 10,
182.82, 12, 186.65, 28, 191.02, 29, 191.11, 32, 191.44




Also



max = list[[1, -1]];
Split[list, Or[Last[#2] < max, max = Last[#2]] &][[All, 1]]



same result




DeleteDuplicates[Join @@ FoldList[MaximalBy[Last] @* Append, First @ list, 
Rest @ list]]



same result




The first method is much faster.






share|improve this answer











$endgroup$



TakeList[list, Length /@ Split[FoldList[Max, list[[All, 2]]]]][[All, 1]]



1, 170.93, 3, 174.08, 7, 175.86, 8, 177.6, 9, 180.27, 10,
182.82, 12, 186.65, 28, 191.02, 29, 191.11, 32, 191.44




Also



max = list[[1, -1]];
Split[list, Or[Last[#2] < max, max = Last[#2]] &][[All, 1]]



same result




DeleteDuplicates[Join @@ FoldList[MaximalBy[Last] @* Append, First @ list, 
Rest @ list]]



same result




The first method is much faster.







share|improve this answer














share|improve this answer



share|improve this answer








edited 7 hours ago

























answered 7 hours ago









kglrkglr

203k10 gold badges232 silver badges463 bronze badges




203k10 gold badges232 silver badges463 bronze badges











  • $begingroup$
    Thank you kglr.
    $endgroup$
    – DestinationLess_Traveller
    6 hours ago










  • $begingroup$
    @DestinationLess_Traveller, thank you for the accept.
    $endgroup$
    – kglr
    6 hours ago
















  • $begingroup$
    Thank you kglr.
    $endgroup$
    – DestinationLess_Traveller
    6 hours ago










  • $begingroup$
    @DestinationLess_Traveller, thank you for the accept.
    $endgroup$
    – kglr
    6 hours ago















$begingroup$
Thank you kglr.
$endgroup$
– DestinationLess_Traveller
6 hours ago




$begingroup$
Thank you kglr.
$endgroup$
– DestinationLess_Traveller
6 hours ago












$begingroup$
@DestinationLess_Traveller, thank you for the accept.
$endgroup$
– kglr
6 hours ago




$begingroup$
@DestinationLess_Traveller, thank you for the accept.
$endgroup$
– kglr
6 hours ago

















draft saved

draft discarded
















































Thanks for contributing an answer to Mathematica Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f201662%2fdelete-elements-less-than-the-last-largest-element%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單