<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: find all rows with value&amp;gt;50 and subsequent 10 rows in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754892#M93727</link>
    <description>&lt;P&gt;Select message &amp;lt;&amp;lt; Select Rows() to data table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

r_start = dt &amp;lt;&amp;lt; Get Rows Where(:weight &amp;gt; 120);
res2 = dt &amp;lt;&amp;lt; get rows where(Any(Row() &amp;gt; r_start &amp;amp; Row() &amp;lt;= r_start + 10));

dt &amp;lt;&amp;lt; Select Rows(res2);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 May 2024 04:58:43 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-05-16T04:58:43Z</dc:date>
    <item>
      <title>find all rows with value&gt;50 and subsequent 10 rows</title>
      <link>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754803#M93712</link>
      <description>&lt;P&gt;I need to write a script to find all rows in the table with value &amp;gt; 50 and return 10 rows right after those rows. Could someone help me with this script please? Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 18:45:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754803#M93712</guid>
      <dc:creator>emmablue</dc:creator>
      <dc:date>2024-05-15T18:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: find all rows with value&gt;50 and subsequent 10 rows</title>
      <link>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754815#M93714</link>
      <description>&lt;P&gt;Without any knowledge of the data you have here is one option you could start with (it looks for values over 120 not 50)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

r = As List(dt &amp;lt;&amp;lt; Get Rows Where(:weight &amp;gt; 120));

rs = {};

max_rows = N Rows(dt);
For Each({cur_r}, r,
	Insert Into(rs, Index(cur_r + 1, Min(max_rows, cur_r + 10)));
);

show(r);
show(rs);

// r = {2, 4, 7, 18, 30, 37, 39, 40};
// rs = {[2 3 4 5 6 7 8 9 10 11], [4 5 6 7 8 9 10 11 12 13], [7 8 9 10 11 12 13 14 15 16], [18 19 20 21 22 23 24 25 26 27], [30 31 32 33 34 35 36 37 38 39], [37 38 39 40], [39 40], [40]};
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 19:00:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754815#M93714</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-05-15T19:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: find all rows with value&gt;50 and subsequent 10 rows</title>
      <link>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754828#M93716</link>
      <description>&lt;P&gt;Here are three different options, they might capture incorrect rows due to off-by-one errors&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Option1
Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

// https://leetcode.com/problems/merge-intervals/solutions/3161191/solution/
merge_intervals = function({intervals}, {Default Local},
	// Assumes array is sorted by first index
	stack = {};
	For Each({interval}, intervals,
		If(N Items(stack) == 0 | stack[N Items(stack)][2] &amp;lt; interval[1],
			Insert Into(stack, Eval List({interval}));
		,
			stack[N Items(stack)][2] = max(stack[N Items(stack)][2], interval[2]);
		);
	);
	return(stack);
);

r_start = (dt &amp;lt;&amp;lt; Get Rows Where(:weight &amp;gt; 120)) + 1;
r_end = r_start  + 10;

toohigh = Loc(r_start &amp;gt; N Rows(dt));
r_start[toohigh] = N Rows(dt);

toohigh = Loc(r_end &amp;gt; N Rows(dt));
r_end[toohigh] = N Rows(dt);

rs = As List(r_start || r_end);

res = merge_intervals(rs);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Option2
Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

r_start = dt &amp;lt;&amp;lt; Get Rows Where(:weight &amp;gt; 120);
res2 = dt &amp;lt;&amp;lt; get rows where(Any(Row() &amp;gt; r_start &amp;amp; Row() &amp;lt;= r_start + 10));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Option3
Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

r = As List(dt &amp;lt;&amp;lt; Get Rows Where(:weight &amp;gt; 120));
rs = {};

max_rows = N Rows(dt);
For Each({cur_r}, r,
	Insert Into(rs, As List(Index(Min(max_rows, cur_r + 1), Min(max_rows, cur_r + 10))));
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 May 2024 19:55:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754828#M93716</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-05-15T19:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: find all rows with value&gt;50 and subsequent 10 rows</title>
      <link>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754831#M93717</link>
      <description>&lt;P&gt;Thank you so much! How can I make rs (all rows selected) into a new data table?&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 20:39:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754831#M93717</guid>
      <dc:creator>emmablue</dc:creator>
      <dc:date>2024-05-15T20:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: find all rows with value&gt;50 and subsequent 10 rows</title>
      <link>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754892#M93727</link>
      <description>&lt;P&gt;Select message &amp;lt;&amp;lt; Select Rows() to data table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

r_start = dt &amp;lt;&amp;lt; Get Rows Where(:weight &amp;gt; 120);
res2 = dt &amp;lt;&amp;lt; get rows where(Any(Row() &amp;gt; r_start &amp;amp; Row() &amp;lt;= r_start + 10));

dt &amp;lt;&amp;lt; Select Rows(res2);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 May 2024 04:58:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754892#M93727</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-05-16T04:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: find all rows with value&gt;50 and subsequent 10 rows</title>
      <link>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754979#M93739</link>
      <description>&lt;P&gt;To make the selected rows into a new data table one just needs to use the Subset Platform.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

r_start = dt &amp;lt;&amp;lt; Get Rows Where(:weight &amp;gt; 120);
res2 = dt &amp;lt;&amp;lt; get rows where(Any(Row() &amp;gt; r_start &amp;amp; Row() &amp;lt;= r_start + 10));

dt &amp;lt;&amp;lt; Select Rows(res2);

dtSub = dt &amp;lt;&amp;lt; subset( selected rows(1), selected columns(0));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 May 2024 18:01:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/find-all-rows-with-value-gt-50-and-subsequent-10-rows/m-p/754979#M93739</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-05-16T18:01:45Z</dc:date>
    </item>
  </channel>
</rss>

