<?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: How do I condition a for loop to work only for a particular set of rows in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/533172#M75601</link>
    <description>&lt;P&gt;Hi, I'm unsure how to use that function, I cant find it in the scripting index, can you show an example? When I try to run the code that you gave, errors pop up.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Aug 2022 02:09:13 GMT</pubDate>
    <dc:creator>PowerOx327</dc:creator>
    <dc:date>2022-08-12T02:09:13Z</dc:date>
    <item>
      <title>How do I condition a for loop to work only for a particular set of rows</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/532813#M75562</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to manipulate a data table with a formula, but I only want it to read for a few rows.&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 );
Open( "$SAMPLE_DATA/Cars.jmp" );

r = Current Data Table() &amp;lt;&amp;lt; Get rows where( :Make == "Mazda");

For( i = r[1], i &amp;lt;= r, i++,
:HeadIC[i] = :HeadIC[i]/2

);

Show(r);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How do I make it so that it only iterates for those selected rows?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:52:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/532813#M75562</guid>
      <dc:creator>PowerOx327</dc:creator>
      <dc:date>2023-06-10T23:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I condition a for loop to work only for a particular set of rows</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/532882#M75565</link>
      <description>&lt;P&gt;Like this?&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 );
Open( "$SAMPLE_DATA/Cars.jmp" );

For Each Row( If ( :Make == "Mazda", :HeadIC = :HeadIC/2 ));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 11:31:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/532882#M75565</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2022-08-11T11:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I condition a for loop to work only for a particular set of rows</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/533044#M75584</link>
      <description>&lt;P&gt;In your example, since you have made the vector with the row numbers, you can also use "For Each()".&amp;nbsp; This would be faster, especially for a larger data table (with may rows).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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 );
Open( "$SAMPLE_DATA/Cars.jmp" );

r = Current Data Table() &amp;lt;&amp;lt; Get rows where( :Make == "Mazda");

for each({cr,ii}, r,
	:headic[cr] = :headic[cr]/2
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 15:18:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/533044#M75584</guid>
      <dc:creator>SamGardner</dc:creator>
      <dc:date>2022-08-11T15:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I condition a for loop to work only for a particular set of rows</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/533097#M75591</link>
      <description>&lt;P&gt;Please demystify this for me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;for each({cr,ii}, r,
	:headic[cr] = :headic[cr]/2
);

// specifically, where do {cr,ii} come from and what do they do?&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not a coder. Couldn't find this in the Scripting Index. Haven't checked the Scripting Guide yet.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 17:50:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/533097#M75591</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2022-08-11T17:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I condition a for loop to work only for a particular set of rows</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/533172#M75601</link>
      <description>&lt;P&gt;Hi, I'm unsure how to use that function, I cant find it in the scripting index, can you show an example? When I try to run the code that you gave, errors pop up.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 02:09:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/533172#M75601</guid>
      <dc:creator>PowerOx327</dc:creator>
      <dc:date>2022-08-12T02:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I condition a for loop to work only for a particular set of rows</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/533219#M75608</link>
      <description>&lt;P&gt;For Each() is new function introduced in JMP16, so if you are using older version of JMP you won't find it in scripting index (and it will give an error). You could convert it to for-loop if you wanted to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Cars.jmp" );

r = Current Data Table() &amp;lt;&amp;lt; Get rows where( :Make == "Mazda");

/*For Each({cr,ii}, r,
	:headic[cr] = :headic[cr]/2
);*/
For(ii = 1, ii &amp;lt;= N Items(r), ii++,
	cr = r[ii];
	:headic[cr] = :headic[cr]/2;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/16.2/#page/jmp/conditional-and-logical-functions.shtml?os=win&amp;amp;source=application#ww10169967" target="_blank" rel="noopener"&gt;For Each(names, container, locals, body) (jmp16 help)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 07:42:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/533219#M75608</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-08-12T07:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I condition a for loop to work only for a particular set of rows</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/533222#M75609</link>
      <description>&lt;P&gt;That's strange. Both work just fine for me. Try again posting the full code of each solution into a separate script window. Close everything else. Run first the code from one script window, confirming that the code does what it is supposed to do. Then, close everything again apart from the other script window containing the code you still need to test.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 07:45:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-condition-a-for-loop-to-work-only-for-a-particular-set/m-p/533222#M75609</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2022-08-12T07:45:39Z</dc:date>
    </item>
  </channel>
</rss>

