<?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 the longest repeating pattern in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Find-the-longest-repeating-pattern/m-p/611185#M81168</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/27815"&gt;@ruskicar&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One possible option is to look at the platform "Explore pattern", accessible through Analyze, Screening, Explore pattern as you mention.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If you click on the red triangle next to "Column 1" in the platform window, you have the option to "Select Longest Duplicate Sequences". It will highlight in your datatable 16 rows, corresponding to 2 times the sequence "1 5 6 8 7 1 5 6", which is the longest repeating sequence you have in your dataset, not "1 5 6 8 7".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this answer will help you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Mar 2023 14:18:20 GMT</pubDate>
    <dc:creator>Victor_G</dc:creator>
    <dc:date>2023-03-13T14:18:20Z</dc:date>
    <item>
      <title>Find the longest repeating pattern</title>
      <link>https://community.jmp.com/t5/Discussions/Find-the-longest-repeating-pattern/m-p/611076#M81162</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can somebody explain how to find the longest repeating pattern in a column?&lt;/P&gt;&lt;P&gt;For example, let's suppose I have the following table:&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="Screenshot 2023-03-13 at 11.40.35.png" style="width: 130px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50951i4368D06C6B3A7AC8/image-dimensions/130x426?v=v2" width="130" height="426" role="button" title="Screenshot 2023-03-13 at 11.40.35.png" alt="Screenshot 2023-03-13 at 11.40.35.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The pattern with the largest size is: "1 5 6 8 7", &amp;nbsp;and it occurs 3 times in this column. Notice that there is another pattern in the table ("1 5 6"), which occurs 5 times, but is not the largest.&lt;/P&gt;&lt;P&gt;I tried with Screening - Explore patterns, and although it return which values are most duplicated, I can't get the exact pattern. Or multiple patterns, with the number of occurrences.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe there is some option I should enable? Or should I use some other platform? Or if somebody can help me out with a JSL script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:29:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-the-longest-repeating-pattern/m-p/611076#M81162</guid>
      <dc:creator>ruskicar</dc:creator>
      <dc:date>2023-06-08T16:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Find the longest repeating pattern</title>
      <link>https://community.jmp.com/t5/Discussions/Find-the-longest-repeating-pattern/m-p/611185#M81168</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/27815"&gt;@ruskicar&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One possible option is to look at the platform "Explore pattern", accessible through Analyze, Screening, Explore pattern as you mention.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If you click on the red triangle next to "Column 1" in the platform window, you have the option to "Select Longest Duplicate Sequences". It will highlight in your datatable 16 rows, corresponding to 2 times the sequence "1 5 6 8 7 1 5 6", which is the longest repeating sequence you have in your dataset, not "1 5 6 8 7".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this answer will help you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 14:18:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-the-longest-repeating-pattern/m-p/611185#M81168</guid>
      <dc:creator>Victor_G</dc:creator>
      <dc:date>2023-03-13T14:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Find the longest repeating pattern</title>
      <link>https://community.jmp.com/t5/Discussions/Find-the-longest-repeating-pattern/m-p/611214#M81169</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11568"&gt;@Victor_G&lt;/a&gt;&amp;nbsp; perfect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wrote this JSL and was unhappy with the answer it provides that includes overlapping duplicates.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// build a sample table
dtElements = New Table( "elements", New Column( "element", Numeric, setvalues( J( 20, 1, Random Integer( 1, 3 ) ) ) ) );
nr = N Rows( dtElements );

// build key table
maxKeyLen = 12; // too big will be slow, too small will miss something
dtKeys = New Table( "keys", addrows( nr ), New Column( "key", expression, Set Display Width( 239 ) ) );

For( irow = 1, irow &amp;lt;= nr, irow += 1,
	maxrow = Min( nr, irow + maxKeyLen );
	dtKeys:key[irow] = dtElements:element[irow :: maxrow];
);

// sort key table to put similar together
dtKeys &amp;lt;&amp;lt; Sort( By( :key ), Replace Table, Order( Ascending ) );

// get the match length of adjacent rows
// ===========================================
// this code finds two runs of 1,1,1 in 1,1,1,1  &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; IMPORTANT &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;
// ===========================================
dtKeys &amp;lt;&amp;lt; New Column( "matchLength" );
For( irow = 2, irow &amp;lt;= nr, irow += 1,
	a = dtKeys:key[irow];
	b = dtKeys:key[irow - 1];
	result = Min( N Items( a ), N Items( b ) );
	For Each( {{aa, bb}, i}, across( a, b, Count( "Shortest" ) ),
		If( aa != bb,
			result = i - 1;
			Break();
		)
	);
	dtKeys:matchLength[irow] = result;
);

dtKeys &amp;lt;&amp;lt; Sort( By( :matchLength ), Replace Table, Order( Descending ) );

Show( dtKeys:key[1][1 :: dtKeys:matchLength[1]] );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The JSL uses an Expression column, ForEach( Across, Count ) and handles both numeric and character input. But I don't think it will quite do what &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/27815"&gt;@ruskicar&lt;/a&gt;&amp;nbsp; wants.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea is to create a new column of values built from the next N rows. Sorting that column puts runs of similar starting patterns adjacent.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 14:31:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-the-longest-repeating-pattern/m-p/611214#M81169</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-03-13T14:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Find the longest repeating pattern</title>
      <link>https://community.jmp.com/t5/Discussions/Find-the-longest-repeating-pattern/m-p/611560#M81188</link>
      <description>&lt;P&gt;Yes, thanks, this is what I was looking for. The example was a bit lousy I see, but the answer is correct :). Too many red triangles, so I didn't spot that option :).&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 21:26:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Find-the-longest-repeating-pattern/m-p/611560#M81188</guid>
      <dc:creator>ruskicar</dc:creator>
      <dc:date>2023-03-13T21:26:42Z</dc:date>
    </item>
  </channel>
</rss>

