<?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: Column mean from certain rows - then populate mean in a new column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Column-mean-from-certain-rows-then-populate-mean-in-a-new-column/m-p/809320#M98915</link>
    <description>&lt;P&gt;You can use Summary and use Join/Update to add it to your original table. Or you can use formula. One such formula is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Mean(If(:Sample ID == "Blank", :Data, .))&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 30 Oct 2024 17:02:52 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-10-30T17:02:52Z</dc:date>
    <item>
      <title>Column mean from certain rows - then populate mean in a new column</title>
      <link>https://community.jmp.com/t5/Discussions/Column-mean-from-certain-rows-then-populate-mean-in-a-new-column/m-p/809318#M98914</link>
      <description>&lt;P&gt;I'd like to calculate a column mean with the condition that it only includes the rows with a certain ID. In this case, I only want to average the data for the Blanks. I'd like the output to populate down a new column. The result will look like this:&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 2024-10-30 at 12.35.16 PM.png" style="width: 233px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69695i001465D1A8B2DE8C/image-dimensions/233x189?v=v2" width="233" height="189" role="button" title="Screenshot 2024-10-30 at 12.35.16 PM.png" alt="Screenshot 2024-10-30 at 12.35.16 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I know how to achieve this with the Table&amp;gt;Summary application, but I don't know how to do it in my data table + have it populate down. Thank you for the help!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2024 16:47:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Column-mean-from-certain-rows-then-populate-mean-in-a-new-column/m-p/809318#M98914</guid>
      <dc:creator>nickicmc5</dc:creator>
      <dc:date>2024-10-30T16:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Column mean from certain rows - then populate mean in a new column</title>
      <link>https://community.jmp.com/t5/Discussions/Column-mean-from-certain-rows-then-populate-mean-in-a-new-column/m-p/809320#M98915</link>
      <description>&lt;P&gt;You can use Summary and use Join/Update to add it to your original table. Or you can use formula. One such formula is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Mean(If(:Sample ID == "Blank", :Data, .))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Oct 2024 17:02:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Column-mean-from-certain-rows-then-populate-mean-in-a-new-column/m-p/809320#M98915</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-30T17:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Column mean from certain rows - then populate mean in a new column</title>
      <link>https://community.jmp.com/t5/Discussions/Column-mean-from-certain-rows-then-populate-mean-in-a-new-column/m-p/809322#M98916</link>
      <description>&lt;P&gt;Thanks for your reply. I need the calculated column mean to be populated into a new column. Here is a script I've been going off of based on playing around with chatgpt, but it's not doing the trick.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Assuming your data table is already open
dt = Current Data Table();

// Calculate the mean of the "Data" column where "Sample ID" is "Blank"
meanValue = Col Mean(If(:Sample ID == "Blank", :Data, Missing()));

// Create a new column for the Blank Average
dt &amp;lt;&amp;lt; New Column("Blank Average", Numeric, Continuous);

// Populate the "Blank Average" column with the calculated mean for all rows
dt &amp;lt;&amp;lt; Set Values(:Blank Average, meanValue);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Oct 2024 17:45:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Column-mean-from-certain-rows-then-populate-mean-in-a-new-column/m-p/809322#M98916</guid>
      <dc:creator>nickicmc5</dc:creator>
      <dc:date>2024-10-30T17:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Column mean from certain rows - then populate mean in a new column</title>
      <link>https://community.jmp.com/t5/Discussions/Column-mean-from-certain-rows-then-populate-mean-in-a-new-column/m-p/809325#M98917</link>
      <description>&lt;P&gt;You can just add what I provided you with as a new formula column and JMP can very easily script that for you after that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would look something like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

Current Data Table() &amp;lt;&amp;lt; New Column("Blank Average", Numeric, Continuous, Formula(
	Col Mean(If(:Sample ID == "Blank", :Data, .))
));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Oct 2024 17:56:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Column-mean-from-certain-rows-then-populate-mean-in-a-new-column/m-p/809325#M98917</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-30T17:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Column mean from certain rows - then populate mean in a new column</title>
      <link>https://community.jmp.com/t5/Discussions/Column-mean-from-certain-rows-then-populate-mean-in-a-new-column/m-p/809332#M98919</link>
      <description>&lt;P&gt;Please take care - Col aggregations like&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Mean(If(:Sample ID == "Blank", :Data, .))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;are very (!!!) slow due to the character comparison in the if expression.&lt;/P&gt;&lt;P&gt;This is ok for a few thousand rows, but for tables with millions of rows, this will take a lot of time.&lt;/P&gt;&lt;P&gt;Better: add a dummy column that maps the character column (:Sample ID) to numeric values and use the numeric column inside the if expression -&amp;gt; orders of magnitude faster!&lt;/P&gt;&lt;P&gt;&lt;LI-MESSAGE title="Tips and Tricks - best practice with JMP/JSL" uid="662686" url="https://community.jmp.com/t5/Discussions/Tips-and-Tricks-best-practice-with-JMP-JSL/m-p/662686#U662686" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2024 20:16:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Column-mean-from-certain-rows-then-populate-mean-in-a-new-column/m-p/809332#M98919</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-10-30T20:16:03Z</dc:date>
    </item>
  </channel>
</rss>

