<?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: use while loop to add rows in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/use-while-loop-to-add-rows/m-p/64956#M34270</link>
    <description>&lt;P&gt;Never mind. I found adding "Rerun Formulas;" can solve the problem. Thank you!&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jul 2018 16:26:17 GMT</pubDate>
    <dc:creator>vistacc</dc:creator>
    <dc:date>2018-07-30T16:26:17Z</dc:date>
    <item>
      <title>use while loop to add rows</title>
      <link>https://community.jmp.com/t5/Discussions/use-while-loop-to-add-rows/m-p/64074#M34206</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I want to continously add rows to an empty data table until a condition is met but I&amp;nbsp;am not sure&amp;nbsp;what to do.&lt;/P&gt;&lt;P&gt;In the following example, the condition is whether all elements in the vector in "steady state" are ones.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ret = New Table( title,
	New Column( "P", Numeric, "Continuous", Formula( ptable &amp;lt;&amp;lt; get as matrix ) ),
	New Column( "X(n)",
		Expression,
		"None",
		Formula( If( Row() == 1, init_state, Lag( :Name( "X(n)" ), 1 ) * :P ) ),
		Set Selected,

	),
	New Column( "steady state",
		Expression,
		"None",
		Formula( :Name( "X(n)" ) - Lag( :Name( "X(n)" ) ) == zeros ),

	),
	New Column( "States", Character, Values( names ) ),

);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;P and init_state are matrices read from a data table. Row values in X(n)&amp;nbsp;are the multiply of the last row values and P. Values in "steady state" column are vectors that consist of zeros and ones, representing whether the elements in two adjacent X(n) vectors are equal or not. I want to add rows to this data table until the vector in "steady state" consists of all ones (i.e. the two adjacent vectors in X(n) are completely equal).&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rownum = N Rows( ret );
cols = Column( ret, "steady state" );
ones = J( 1, vectorlength, 1 );
While((!vectorEqual(cols[rownum],ones)),
	// add rows here, not sure how
	rownum = N Rows( ret );
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Another question is that I add command "show(cols[rownum])" to check whether the selected value is correct but it shows Empty()... Is it because that since all values are not added to the table at the first place so I cannot refer to them? If so, how can I check for the condition?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would greatly appreciate any help!&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jul 2018 14:08:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/use-while-loop-to-add-rows/m-p/64074#M34206</guid>
      <dc:creator>vistacc</dc:creator>
      <dc:date>2018-07-27T14:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: use while loop to add rows</title>
      <link>https://community.jmp.com/t5/Discussions/use-while-loop-to-add-rows/m-p/64103#M34223</link>
      <description>&lt;P&gt;Concerning the adding of rows, I assume that all you need to do is to add&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rownum = N Rows( ret );
cols = Column( ret, "steady state" );
ones = J( 1, vectorlength, 1 );
While((!vectorEqual(cols[rownum],ones)),
	ret &amp;lt;&amp;lt; add rows(1);
        dt &amp;lt;&amp;lt; Rerun Formulas;
	rownum = N Rows( ret );
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Jul 2018 19:24:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/use-while-loop-to-add-rows/m-p/64103#M34223</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-07-27T19:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: use while loop to add rows</title>
      <link>https://community.jmp.com/t5/Discussions/use-while-loop-to-add-rows/m-p/64942#M34265</link>
      <description>&lt;P&gt;Thank you so much! it works!&lt;/P&gt;&lt;P&gt;I still have trouble getting the cell value in the last row of the columns. As mentioned, it shows "Empty()" in the Log window. I guess the problem is that those values are assigned using formulas so they are Empty() when I tried to access them. What scripts should I use to get the values of those cells?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 15:54:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/use-while-loop-to-add-rows/m-p/64942#M34265</guid>
      <dc:creator>vistacc</dc:creator>
      <dc:date>2018-07-30T15:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: use while loop to add rows</title>
      <link>https://community.jmp.com/t5/Discussions/use-while-loop-to-add-rows/m-p/64956#M34270</link>
      <description>&lt;P&gt;Never mind. I found adding "Rerun Formulas;" can solve the problem. Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 16:26:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/use-while-loop-to-add-rows/m-p/64956#M34270</guid>
      <dc:creator>vistacc</dc:creator>
      <dc:date>2018-07-30T16:26:17Z</dc:date>
    </item>
  </channel>
</rss>

