<?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 Evaluating Col Mean with Iterations in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Evaluating-Col-Mean-with-Iterations/m-p/55275#M31255</link>
    <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having trouble evaluating a col mean function. As you can see below, the col mean(:age, :list_col_names[i]] doesnt insert the item in the list on the data table. With this current configuration, when I open the formula on the data table I get "Col Mean( :age, list_col_names[i] )" which doesnt correspond to anything on the list_col_names list.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;list_col_names = fdt &amp;lt;&amp;lt; getColumnNames( "String" );

For( j = N Items( list_col_names ), j &amp;gt; 0, j--,
	If( Left( list_col_names[j], 2 ) != "10",
		Remove From( list_col_names, j )
	)
);

For( i = 1, i &amp;lt;= N Items( list_col_names ), i++,&lt;BR /&gt; fdt &amp;lt;&amp;lt; New Column( list_col_names[i] || "_age", Numeric, Formula( Col Mean( :age, :list_col_names[i] ) ) ) &lt;BR /&gt;);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;on in an iteration&lt;/P&gt;</description>
    <pubDate>Thu, 19 Apr 2018 18:19:29 GMT</pubDate>
    <dc:creator>Ksrzg01</dc:creator>
    <dc:date>2018-04-19T18:19:29Z</dc:date>
    <item>
      <title>Evaluating Col Mean with Iterations</title>
      <link>https://community.jmp.com/t5/Discussions/Evaluating-Col-Mean-with-Iterations/m-p/55275#M31255</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having trouble evaluating a col mean function. As you can see below, the col mean(:age, :list_col_names[i]] doesnt insert the item in the list on the data table. With this current configuration, when I open the formula on the data table I get "Col Mean( :age, list_col_names[i] )" which doesnt correspond to anything on the list_col_names list.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;list_col_names = fdt &amp;lt;&amp;lt; getColumnNames( "String" );

For( j = N Items( list_col_names ), j &amp;gt; 0, j--,
	If( Left( list_col_names[j], 2 ) != "10",
		Remove From( list_col_names, j )
	)
);

For( i = 1, i &amp;lt;= N Items( list_col_names ), i++,&lt;BR /&gt; fdt &amp;lt;&amp;lt; New Column( list_col_names[i] || "_age", Numeric, Formula( Col Mean( :age, :list_col_names[i] ) ) ) &lt;BR /&gt;);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;on in an iteration&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 18:19:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Evaluating-Col-Mean-with-Iterations/m-p/55275#M31255</guid>
      <dc:creator>Ksrzg01</dc:creator>
      <dc:date>2018-04-19T18:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating Col Mean with Iterations</title>
      <link>https://community.jmp.com/t5/Discussions/Evaluating-Col-Mean-with-Iterations/m-p/55281#M31259</link>
      <description>&lt;P&gt;you can't do :list_col_names[i], You're explicitly stating that you have a column called "list_col_names" and you're pulling the ith row of it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try 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);
fdt = open("$SAMPLE_DATA\Big Class.jmp");
list_col_names = {"sex", "name"};

For( i = 1, i &amp;lt;= N Items( list_col_names ), i++,
	//this is just it doesn't keep the variable 
	//in the table because i will change and then your column name will change
	Eval(
		EvalExpr(
			fdt &amp;lt;&amp;lt; New Column( list_col_names[i] || "_age", 
				Numeric, 
				Formula( Col Mean( :age, 
					//replaces the string column name with an actual column
					Expr(Column(fdt, list_col_names[i]))
						
				) ) 
			)
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Apr 2018 23:00:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Evaluating-Col-Mean-with-Iterations/m-p/55281#M31259</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2018-04-19T23:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating Col Mean with Iterations</title>
      <link>https://community.jmp.com/t5/Discussions/Evaluating-Col-Mean-with-Iterations/m-p/55299#M31273</link>
      <description>&lt;P&gt;Works great. Thank you Vince!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 14:38:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Evaluating-Col-Mean-with-Iterations/m-p/55299#M31273</guid>
      <dc:creator>Ksrzg01</dc:creator>
      <dc:date>2018-04-20T14:38:52Z</dc:date>
    </item>
  </channel>
</rss>

