<?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: Filter by row, stack columns? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380082#M63019</link>
    <description>&lt;P&gt;Here is how I thought it can be done (but it is not working):&lt;/P&gt;&lt;PRE&gt;my_list = {"F0","F1"};
stackcols = {};
For( i = 1, i &amp;lt;= N Items( my_list ), i++,
	dt &amp;lt;&amp;lt; Row Selection( Select where( (:Freq==my_list[i]), Current Selection( "Extend" )) );
	dt &amp;lt;&amp;lt; Select Columns( [19] );
	Insert Into( stackcols, dt )
);
dt2 &amp;lt;&amp;lt; Subset( Output Table( "aa"), Selected Rows( 1 ), Selected columns( 1 ) );&lt;/PRE&gt;&lt;P&gt;Basically, I filter the active table according to column "Freq", first by the value "F0" and then by "F1". This is located in Column 19. I add that selection to the selection list called 'stackcols'. So after the loop I am expecting this to be a two columns-wide list. Then I want to make a table out of it (Called "aa"). But it is not working.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Apr 2021 15:21:23 GMT</pubDate>
    <dc:creator>student</dc:creator>
    <dc:date>2021-04-27T15:21:23Z</dc:date>
    <item>
      <title>Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380055#M63016</link>
      <description>&lt;P&gt;I know how to make a subset table based on some criteria:&lt;/P&gt;&lt;PRE&gt;dt &amp;lt;&amp;lt; Row Selection( Select where( (:Stat == "mean"), Current Selection( Extend )) );
dt &amp;lt;&amp;lt; Select Columns( [10, 20] );
dt2 &amp;lt;&amp;lt; Subset( Output Table( "test"), Selected Rows( 1 ), Selected columns( 1 ) );&lt;/PRE&gt;&lt;P&gt;But now I need to repeat the above for multiple criteria and stack the selection, i.e. the new table will have Column 10 as a fixed column, and then I keep adding column 20 with only the rows matching the criteria above. The number of rows will always be the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The "Stack" command does not work with selection, so am not sure what other commands can do that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:45:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380055#M63016</guid>
      <dc:creator>student</dc:creator>
      <dc:date>2023-06-09T19:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380068#M63017</link>
      <description>&lt;P&gt;Here is an example of an easy way to delete the selected rows when using the Stack platform&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dt &amp;lt;&amp;lt; Row Selection( Select where( (:Sex=="F"), Current Selection( "Extend" )) );

// Stack data table
dtStack = dt &amp;lt;&amp;lt; Stack(
	columns( :height, :weight ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" )
);

dtStack &amp;lt;&amp;lt; delete rows;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Apr 2021 14:59:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380068#M63017</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-04-27T14:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380077#M63018</link>
      <description>(Hit accept as solution by mistake)&lt;BR /&gt;&lt;BR /&gt;Thanks but I don't want to delete selected rows. I can take care of that, but how would I append the selection when using Stack?</description>
      <pubDate>Tue, 27 Apr 2021 15:09:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380077#M63018</guid>
      <dc:creator>student</dc:creator>
      <dc:date>2021-04-27T15:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380082#M63019</link>
      <description>&lt;P&gt;Here is how I thought it can be done (but it is not working):&lt;/P&gt;&lt;PRE&gt;my_list = {"F0","F1"};
stackcols = {};
For( i = 1, i &amp;lt;= N Items( my_list ), i++,
	dt &amp;lt;&amp;lt; Row Selection( Select where( (:Freq==my_list[i]), Current Selection( "Extend" )) );
	dt &amp;lt;&amp;lt; Select Columns( [19] );
	Insert Into( stackcols, dt )
);
dt2 &amp;lt;&amp;lt; Subset( Output Table( "aa"), Selected Rows( 1 ), Selected columns( 1 ) );&lt;/PRE&gt;&lt;P&gt;Basically, I filter the active table according to column "Freq", first by the value "F0" and then by "F1". This is located in Column 19. I add that selection to the selection list called 'stackcols'. So after the loop I am expecting this to be a two columns-wide list. Then I want to make a table out of it (Called "aa"). But it is not working.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 15:21:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380082#M63019</guid>
      <dc:creator>student</dc:creator>
      <dc:date>2021-04-27T15:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380083#M63020</link>
      <description>&lt;P&gt;Ah.....you are correct about deleting the selected rows.&amp;nbsp; But to delete the non selected, just use&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dtStack &amp;lt;&amp;lt; Invert Row Selection;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then delete the rows.&lt;/P&gt;
&lt;P&gt;To append multiple independent Stacked data tables, simply:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Before starting the repeating Stack instances, create an empty Base data table that will end up having all of the stacked tables concatenated to it
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dtBase = New Table("Base");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Then for each of the stacked tables you create,&amp;nbsp;
&lt;OL&gt;
&lt;LI&gt;Delete the rows you do not want from the stacked data table&lt;/LI&gt;
&lt;LI&gt;Concatenate the Stacked table to the Base table
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dtBase &amp;lt;&amp;lt; Concatenate( dtStacked );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Delete the Stacked table
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Close( dtStacked, nosave );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 27 Apr 2021 15:24:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380083#M63020</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-04-27T15:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380084#M63021</link>
      <description>&lt;P&gt;Thanks, but it didn't work:&lt;/P&gt;&lt;PRE&gt;dt = current data table();
my_list = {"F0","F1"};
dtBase = New Table("Base");
dtStacked = {};
For( i = 1, i &amp;lt;= N Items( my_list ), i++,
	dt &amp;lt;&amp;lt; Row Selection( Select where( (:Freq==my_list[i]), Current Selection( "Extend" )) );
	dt &amp;lt;&amp;lt; Select Columns( [19] );
	Insert Into( dtStacked, dt );
	dtBase &amp;lt;&amp;lt; Concatenate( dtStacked );
	Close( dtStacked, nosave );
);&lt;/PRE&gt;&lt;P&gt;dtBase is empty.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 15:36:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380084#M63021</guid>
      <dc:creator>student</dc:creator>
      <dc:date>2021-04-27T15:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380090#M63025</link>
      <description>&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/16.0/#page/jmp/list-functions.shtml#ww2474384" target="_self"&gt;Insert Into()&lt;/A&gt; doesn't do what it appears you think it does.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your code it would insert the data table reference dt into the dtstacked list repeatedly. It doesn't have anything to do with the selected rows or columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll need to create a new data table of the selected rows and columns using Subset() and insert that reference into dtstacked and then concatenate them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Though, that doesn't seem necessary. Since you're just extending the selection each time through the loop at the very end you could do a subset of the selected rows and column and get the same result as your concatenated data table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 16:23:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380090#M63025</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2021-04-27T16:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380091#M63026</link>
      <description>Thanks, that is almost what I want, except I need them stacked (column-wise) instead of concatenated (row-wise). That is, if selection column is L long, I want my new table to have same number of rows, but two columns (not one column of twice the length).</description>
      <pubDate>Tue, 27 Apr 2021 16:31:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380091#M63026</guid>
      <dc:creator>student</dc:creator>
      <dc:date>2021-04-27T16:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380092#M63027</link>
      <description>&lt;P&gt;To not concatenate, but rather to add new columns then simply use the Update platform.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 16:36:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380092#M63027</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-04-27T16:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380093#M63028</link>
      <description>&lt;P&gt;Here is a code that seems to work, manually. Now I will try to do it in a loop:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;dt &amp;lt;&amp;lt; Row Selection( Select where( (:Stat == "selection1"), Current Selection( Extend )) );
dt &amp;lt;&amp;lt; Select Columns( [15, 19] );

dt &amp;lt;&amp;lt; Row Selection( Select where( (:Stat == "selection2"), Current Selection( Extend )) );
dt &amp;lt;&amp;lt; Select Columns( [15, 19] );
dt &amp;lt;&amp;lt; Subset( ( Selected Columns ), Output Table Name( "Subset_1_2" ) );&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Apr 2021 16:36:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380093#M63028</guid>
      <dc:creator>student</dc:creator>
      <dc:date>2021-04-27T16:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380094#M63029</link>
      <description>&lt;P&gt;No, the above code still concatenate. I'll try "update" command.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 16:43:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380094#M63029</guid>
      <dc:creator>student</dc:creator>
      <dc:date>2021-04-27T16:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380096#M63030</link>
      <description>&lt;P&gt;I apologize for the many posts. I am still stuck. Right now all what I have is this script that results in two tables, each having one column that I am interested in. I am able to manually copy and paste one column from table 1 to table 2, but can't do it automatically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;dt &amp;lt;&amp;lt; Row Selection( Select where( (:Freq == "F0"), Current Selection( Extend )) );
dt &amp;lt;&amp;lt; Select Columns( [15,19] );
dt &amp;lt;&amp;lt; Subset( ( Selected Columns ), Output Table Name( "F0" ) );

dt &amp;lt;&amp;lt; clear select;
dt &amp;lt;&amp;lt; Row Selection( Select where( (:Freq == "F1"), Current Selection( Extend )) );
dt &amp;lt;&amp;lt; Select Columns( [15,19] );
dt &amp;lt;&amp;lt; Subset( ( Selected Columns ), Output Table Name( "F1" ) );&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Apr 2021 17:10:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380096#M63030</guid>
      <dc:creator>student</dc:creator>
      <dc:date>2021-04-27T17:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380129#M63034</link>
      <description>&lt;P&gt;I suspect the issue is that the columns in both tables have the same names.&amp;nbsp; Therefore, JMP will overwrite the values.&amp;nbsp; Here is a simple example on how I would handle this.&amp;nbsp; Now, given this type of Update, the two data tables will be lined up, row 1 with row 1.&lt;/P&gt;
&lt;P&gt;That may result in the issue that you can not compare across columns, since the relationship between them does not exist.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Row Selection( Select where( (:Freq == "F0"), Current Selection( Extend )) );
dt &amp;lt;&amp;lt; Select Columns( [15,19] );
dt2 = dt &amp;lt;&amp;lt; Subset( ( Selected Columns ), Output Table Name( "F0" ) );

dt &amp;lt;&amp;lt; clear select;
dt &amp;lt;&amp;lt; Row Selection( Select where( (:Freq == "F1"), Current Selection( Extend )) );
dt &amp;lt;&amp;lt; Select Columns( [15,19] );
dt3 = dt &amp;lt;&amp;lt; Subset( ( Selected Columns ), Output Table Name( "F1" ) );

// Rename the columns
column(dt3,1) &amp;lt;&amp;lt;set name((column(dt3,1) &amp;lt;&amp;lt; get name) || " 2");
column(dt3,2) &amp;lt;&amp;lt;set name((column(dt3,2) &amp;lt;&amp;lt; get name) || " 2");

// Merge the data tables
dt2 &amp;lt;&amp;lt; update(with(dt3));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Apr 2021 18:02:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380129#M63034</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-04-27T18:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380200#M63048</link>
      <description>&lt;P&gt;Thanks, that was correct! Only thing remaining is how to put it in a for loop. Here is my trial:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;For(i=1, i&amp;lt;=NItems(freq_list), i++,
	dt &amp;lt;&amp;lt; clear select;
	dt &amp;lt;&amp;lt; Row Selection( Select where( (:Freq == (freq_list[i])), Current Selection( Extend )) );
	dt &amp;lt;&amp;lt; Select Columns( [15,19] );
	dt &amp;lt;&amp;lt; Subset( ( Selected Columns ), Output Table Name( freq_list[i] ) );
);&lt;/PRE&gt;&lt;P&gt;But this produces two identical tables even though I clear the selection at the start of each loop.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 19:09:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380200#M63048</guid>
      <dc:creator>student</dc:creator>
      <dc:date>2021-04-27T19:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380276#M63060</link>
      <description>&lt;P&gt;Rethinking of what I am guessing is your desired final table output, I suggest that you take a look at&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Tables=&amp;gt;Split&lt;/P&gt;
&lt;P&gt;The example below splits by the :Sex column, it would be your :Freq column, and the Split columns are Height and Weight, which would be your 15 and 19 columns.&lt;/P&gt;
&lt;P&gt;The output creates pairs of columns for each of the Split By column values&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = open("$SAMPLE_DATA\big class.jmp");

// Split data table
// → Data Table( "Untitled 66" )
Data Table( "big class" ) &amp;lt;&amp;lt; Split(
	Split By( :Sex ),
	Split( :height, :weight ),
	Remaining Columns( Drop All ),
	Sort by Column Property
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="split.PNG" style="width: 346px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/32370i4426E81EEE8C9B61/image-size/large?v=v2&amp;amp;px=999" role="button" title="split.PNG" alt="split.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 21:47:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380276#M63060</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-04-27T21:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Filter by row, stack columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380292#M63064</link>
      <description>&lt;P&gt;That is actually what I wanted, thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 23:03:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Filter-by-row-stack-columns/m-p/380292#M63064</guid>
      <dc:creator>student</dc:creator>
      <dc:date>2021-04-27T23:03:41Z</dc:date>
    </item>
  </channel>
</rss>

