<?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: JSL select rows near the maximum value of a column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-select-rows-near-the-maximum-value-of-a-column/m-p/534363#M75696</link>
    <description>&lt;P&gt;If there happen to be multiple rows that are at max you could do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
dt = New Table( "Test",
	Add Rows( 46 ),
	New Column( "x",
		Set Values(
			[1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4,
			2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9,
			4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5, 5.1, 5.2, 5.3, 5.4,
			5.5]
		)
	),
	New Column( "y",
		Set Values(
			[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
			1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
			1]
		)
	)
);
mxrow = dt &amp;lt;&amp;lt; get rows where (:y == col max(:y) );
mxx = dt:x[mxrow];
dt &amp;lt;&amp;lt; select where (Any(mxx - 0.3 &amp;lt;= :x &amp;lt; mxx + 0.3));

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :x ), Y( :y ) ),
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vince_faller_0-1660671897366.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/44813iCEC82DFAE2070E0B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vince_faller_0-1660671897366.png" alt="vince_faller_0-1660671897366.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The unselected point on the second peak is because of floating error.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Aug 2022 17:45:59 GMT</pubDate>
    <dc:creator>vince_faller</dc:creator>
    <dc:date>2022-08-16T17:45:59Z</dc:date>
    <item>
      <title>JSL select rows near the maximum value of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-select-rows-near-the-maximum-value-of-a-column/m-p/530884#M75407</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a data series shown in the screenshot below, and try to select only the data in the range of "x +/- 0.3" with the center at the maximum value of "y".&lt;/P&gt;&lt;P&gt;I got an error message "The argument to SelectWhere did not evaluate to true or false, it is [0]..." from the highlighted line, as shown below. What is puzzling is that the last line worked when only 1 condition is applied.&lt;/P&gt;&lt;P&gt;What is wrong with the script in line 6? Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CurseOfLizard13_0-1659708437088.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/44601i88D1A2AF144D8C7E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CurseOfLizard13_0-1659708437088.png" alt="CurseOfLizard13_0-1659708437088.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = current data table();
mxrow = dt &amp;lt;&amp;lt; get rows where (:y == col max(:y) );
mxx = dt:x[mxrow];
print (mxrow, mxx);
dt &amp;lt;&amp;lt; select where (:x &amp;lt; mxx + 0.3 &amp;amp; :x &amp;gt; mxx - 0.3);
dt &amp;lt;&amp;lt; select where (:x &amp;lt; mxx + 0.3);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:06:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-select-rows-near-the-maximum-value-of-a-column/m-p/530884#M75407</guid>
      <dc:creator>CurseOfLizard13</dc:creator>
      <dc:date>2023-06-09T17:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: JSL select rows near the maximum value of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-select-rows-near-the-maximum-value-of-a-column/m-p/530904#M75409</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Try using the following syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; select where (eval (mxx - 0.3) &amp;lt;= :x &amp;lt; eval (mxx + 0.3));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2022 14:58:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-select-rows-near-the-maximum-value-of-a-column/m-p/530904#M75409</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2022-08-05T14:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: JSL select rows near the maximum value of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-select-rows-near-the-maximum-value-of-a-column/m-p/533238#M75612</link>
      <description>&lt;P&gt;I think JMP doesn't like that you are comparing matrices to single numbers.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled", Add Rows(3), New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3])));

max_x = [2];
dt &amp;lt;&amp;lt; Select Where(:Column 1 &amp;gt; max_x); // will print message to log

wait(2);

min_x = 2;
dt &amp;lt;&amp;lt; Select Where(:Column 1 &amp;lt; min_x);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2022 08:06:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-select-rows-near-the-maximum-value-of-a-column/m-p/533238#M75612</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-08-12T08:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: JSL select rows near the maximum value of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-select-rows-near-the-maximum-value-of-a-column/m-p/533873#M75662</link>
      <description>&lt;P&gt;So to get around your problem, just index into the first value of your mxx:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = current data table();
mxrow = dt &amp;lt;&amp;lt; get rows where (:y == col max(:y) );
mxx = (dt:x[mxrow])[1]; //Index into the matrix and extract the first item
print (mxrow, mxx);
dt &amp;lt;&amp;lt; select where (:x &amp;lt; mxx + 0.3 &amp;amp; :x &amp;gt; mxx - 0.3);
dt &amp;lt;&amp;lt; select where (:x &amp;lt; mxx + 0.3);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Aug 2022 15:11:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-select-rows-near-the-maximum-value-of-a-column/m-p/533873#M75662</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2022-08-15T15:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: JSL select rows near the maximum value of a column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-select-rows-near-the-maximum-value-of-a-column/m-p/534363#M75696</link>
      <description>&lt;P&gt;If there happen to be multiple rows that are at max you could do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
dt = New Table( "Test",
	Add Rows( 46 ),
	New Column( "x",
		Set Values(
			[1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4,
			2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9,
			4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5, 5.1, 5.2, 5.3, 5.4,
			5.5]
		)
	),
	New Column( "y",
		Set Values(
			[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
			1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
			1]
		)
	)
);
mxrow = dt &amp;lt;&amp;lt; get rows where (:y == col max(:y) );
mxx = dt:x[mxrow];
dt &amp;lt;&amp;lt; select where (Any(mxx - 0.3 &amp;lt;= :x &amp;lt; mxx + 0.3));

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :x ), Y( :y ) ),
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vince_faller_0-1660671897366.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/44813iCEC82DFAE2070E0B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vince_faller_0-1660671897366.png" alt="vince_faller_0-1660671897366.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The unselected point on the second peak is because of floating error.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 17:45:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-select-rows-near-the-maximum-value-of-a-column/m-p/534363#M75696</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2022-08-16T17:45:59Z</dc:date>
    </item>
  </channel>
</rss>

