<?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: Scripting average of last five points for each row type in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Scripting-average-of-last-five-points-for-each-row-type/m-p/39002#M22802</link>
    <description>&lt;P&gt;You can just create a new table using the keys and values of the associative array:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dtSummary = New Table( "Summary",
	New Column( "ID", "Character", Set Values( avgs &amp;lt;&amp;lt; Get Keys ) ),
	New Column( "Average", "Numeric", Set Values( avgs &amp;lt;&amp;lt; Get Values ) )
);&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 May 2017 19:23:28 GMT</pubDate>
    <dc:creator>Melanie_J_Drake</dc:creator>
    <dc:date>2017-05-08T19:23:28Z</dc:date>
    <item>
      <title>Scripting average of last five points for each row type</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-average-of-last-five-points-for-each-row-type/m-p/38986#M22794</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am having issues trying to figure out the best way to average only the last five data points for each row identifier using jsl. I tried to set a sequence and then delete the first x points of the sequence, but the issue is that not each row identifier has the same number of rows. The number of identifiers is also subject to change based on the data pull.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Ex, for the following table I want to output the mean of just the last five points from A, B and C (but the identifier list could go all the way up to Z):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="example table.PNG" style="width: 255px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/6119i26374ED7956D2B59/image-size/large?v=v2&amp;amp;px=999" role="button" title="example table.PNG" alt="example table.PNG" /&gt;&lt;/span&gt;&lt;/P&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>Mon, 08 May 2017 14:17:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-average-of-last-five-points-for-each-row-type/m-p/38986#M22794</guid>
      <dc:creator>megball</dc:creator>
      <dc:date>2017-05-08T14:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting average of last five points for each row type</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-average-of-last-five-points-for-each-row-type/m-p/38987#M22795</link>
      <description>&lt;P&gt;Would something like this work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;avgs = Associative Array( dt:ID );
ids = avgs &amp;lt;&amp;lt; get keys;

For( i = 1, i &amp;lt;= N Items(ids), i++,
	these = As List( dt &amp;lt;&amp;lt; get rows where( dt:ID == ids[i] ) );
	If( N Items(these) &amp;lt; 5, 
		n =  N Items(these),
		n = 5;
		Remove From( these, 1, N Items(these) - n );
	);
	these = Matrix( these );
	avgs[ids[i]] = Sum(dt:Value[these]) / n;
);

Show(avgs);
&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 May 2017 14:52:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-average-of-last-five-points-for-each-row-type/m-p/38987#M22795</guid>
      <dc:creator>Melanie_J_Drake</dc:creator>
      <dc:date>2017-05-08T14:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting average of last five points for each row type</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-average-of-last-five-points-for-each-row-type/m-p/39001#M22801</link>
      <description>&lt;P&gt;Thank you! I was able to adapt this to what I needed. The next question is though, how can I spit these average values out to a summary table?&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 18:55:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-average-of-last-five-points-for-each-row-type/m-p/39001#M22801</guid>
      <dc:creator>megball</dc:creator>
      <dc:date>2017-05-08T18:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting average of last five points for each row type</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-average-of-last-five-points-for-each-row-type/m-p/39002#M22802</link>
      <description>&lt;P&gt;You can just create a new table using the keys and values of the associative array:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dtSummary = New Table( "Summary",
	New Column( "ID", "Character", Set Values( avgs &amp;lt;&amp;lt; Get Keys ) ),
	New Column( "Average", "Numeric", Set Values( avgs &amp;lt;&amp;lt; Get Values ) )
);&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 May 2017 19:23:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-average-of-last-five-points-for-each-row-type/m-p/39002#M22802</guid>
      <dc:creator>Melanie_J_Drake</dc:creator>
      <dc:date>2017-05-08T19:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting average of last five points for each row type</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-average-of-last-five-points-for-each-row-type/m-p/39007#M22806</link>
      <description>&lt;P&gt;Works like a charm, thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 20:46:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-average-of-last-five-points-for-each-row-type/m-p/39007#M22806</guid>
      <dc:creator>megball</dc:creator>
      <dc:date>2017-05-08T20:46:41Z</dc:date>
    </item>
  </channel>
</rss>

