<?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 Script for table processing JMP14 in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779830#M96116</link>
    <description>&lt;P&gt;Hi. Could you please help me to write a script that takes the original table and make a new table out of it? Original table has two lines per each sample temperature measurement. In the output table we use only one row per each sample and calculate number of the days between the two measurements and the temperature delta.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Aug 2024 08:54:08 GMT</pubDate>
    <dc:creator>EvgenyShelegeda</dc:creator>
    <dc:date>2024-08-07T08:54:08Z</dc:date>
    <item>
      <title>Script for table processing JMP14</title>
      <link>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779830#M96116</link>
      <description>&lt;P&gt;Hi. Could you please help me to write a script that takes the original table and make a new table out of it? Original table has two lines per each sample temperature measurement. In the output table we use only one row per each sample and calculate number of the days between the two measurements and the temperature delta.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 08:54:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779830#M96116</guid>
      <dc:creator>EvgenyShelegeda</dc:creator>
      <dc:date>2024-08-07T08:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Script for table processing JMP14</title>
      <link>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779840#M96117</link>
      <description>&lt;P&gt;Could you provide the example data as JMP table so we don't have to create it from the image (formats can have big impact on the script)&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 09:16:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779840#M96117</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-07T09:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Script for table processing JMP14</title>
      <link>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779845#M96119</link>
      <description>&lt;P&gt;You could add two formula columns that calculate the maximum - minimum for each sample (temperature and date):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pauldeen_1-1723023367666.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66914i28EA1578652DF8ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pauldeen_1-1723023367666.png" alt="pauldeen_1-1723023367666.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Or run below script to get your example table with formula columns.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "Example",
	Add Rows( 8 ),
	New Column( "Sample",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 1, 2, 2, 3, 3, 99, 99] )
	),
	New Column( "Temperature",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [199, 210, 201, 217, 200, 215, 199, 220] )
	),
	New Column( "Temp Diff",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			Col Maximum( :Temperature, :Sample )
			-Col Minimum( :Temperature, :Sample )
		)
	),
	New Column( "Date (ISO 9601 format)",
		Numeric,
		"Continuous",
		Format( "yyyy-mm-dd", 10 ),
		Input Format( "yyyy-mm-dd" ),
		Set Values(
			[3795552000, 3798576000, 3795552000, 3798748800, 3795552000, 3798662400,
			3795552000, 3798921600]
		)
	),
	New Column( "Date Diff",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			Date Difference(
				Col Minimum( :"Date (ISO 9601 format)"n, :Sample ),
				Col Maximum( :"Date (ISO 9601 format)"n, :Sample ),
				"Day"
			)
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And then a quick summary will give you the table you were after:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pauldeen_0-1723023333676.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66913i54676E31FA93C2BE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pauldeen_0-1723023333676.png" alt="pauldeen_0-1723023333676.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 09:36:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779845#M96119</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2024-08-07T09:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Script for table processing JMP14</title>
      <link>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779847#M96121</link>
      <description>&lt;P&gt;Hi Jarmo. Thanks for your support. Please find attached.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 10:06:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779847#M96121</guid>
      <dc:creator>EvgenyShelegeda</dc:creator>
      <dc:date>2024-08-07T10:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Script for table processing JMP14</title>
      <link>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779848#M96122</link>
      <description>&lt;P&gt;Hi Paul. Thanks for your idea. Will this approach work if the temperature delta sometimes is negative, and it is critical for me?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 10:16:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779848#M96122</guid>
      <dc:creator>EvgenyShelegeda</dc:creator>
      <dc:date>2024-08-07T10:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Script for table processing JMP14</title>
      <link>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779849#M96123</link>
      <description>&lt;P&gt;Okay. I checked, it is not working. Can we use some other formula to pick the temperature measurement from the later date and from the earlier date?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 10:34:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779849#M96123</guid>
      <dc:creator>EvgenyShelegeda</dc:creator>
      <dc:date>2024-08-07T10:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Script for table processing JMP14</title>
      <link>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779862#M96125</link>
      <description>&lt;P&gt;You can use following formulas&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;:Temperature - (Col Moving Average(:Temperature, 1, 1, 0, :Sample) * 2 - :Temperature)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;(:Date - (Col Moving Average(:Date, 1, 1, 0, :Sample) * 2 - :Date)) / In Days(1)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to calculate the deltas.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1723027022183.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66915i67CF46B5A6FAC267/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1723027022183.png" alt="jthi_0-1723027022183.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Then either create new table without the 0 rows (don't include formulas in that table) or remove formulas and delete those 0 rows.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1723027264904.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66916i3FC60A406F88C302/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1723027264904.png" alt="jthi_1-1723027264904.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this script should work for JMP14 (I cannot test it as I don't have access to that)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/source table.jmp");

dt &amp;lt;&amp;lt; New Column("Time Delta", Numeric, "Continuous", Formula(
	:Temperature - (Col Moving Average(:Temperature, 1, 1, 0, :Sample) * 2
	- :Temperature)
));

dt &amp;lt;&amp;lt; New Column("Temperature Delta", Numeric, "Continuous", Formula(
	(:Date - (Col Moving Average(:Date, 1, 1, 0, :Sample) * 2 - :Date)) /
	In Days(1)
));

dt &amp;lt;&amp;lt; Select Where(:Temperature Delta == 0) &amp;lt;&amp;lt; Invert Row Selection;

dt_subset = dt &amp;lt;&amp;lt; Subset(
	Copy formula(0),
	Selected Rows(1),
	Columns({"Sample", "Time Delta", "Temperature Delta"}),
	Output Table("Deltas")
);

dt &amp;lt;&amp;lt; Clear Select;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Aug 2024 10:41:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779862#M96125</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-07T10:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Script for table processing JMP14</title>
      <link>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779863#M96126</link>
      <description>&lt;P&gt;Kiitos Jarmo. Let me try it.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 10:46:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779863#M96126</guid>
      <dc:creator>EvgenyShelegeda</dc:creator>
      <dc:date>2024-08-07T10:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Script for table processing JMP14</title>
      <link>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779866#M96129</link>
      <description>&lt;P&gt;Jarmo, thanks a lot for your solution. It is working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I have two more questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Could you please explain what does the formula with Moving Average calculation does? I just want to understand the logic of your approach...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. I just noticed that if the first line goes with later date, it gives the negative Time delta... The Time Delta should always be positive. Will it work if I sort the source table in the very beginning so your script works correctly?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 12:07:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779866#M96129</guid>
      <dc:creator>EvgenyShelegeda</dc:creator>
      <dc:date>2024-08-07T12:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Script for table processing JMP14</title>
      <link>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779867#M96130</link>
      <description>&lt;P&gt;Sorting should work, but you could consider also other formulas if that is the case (if the order is always later - earlier).&amp;nbsp; I use Col Moving Average, so I can access to value from earlier row for the group.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 12:14:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-for-table-processing-JMP14/m-p/779867#M96130</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-07T12:14:46Z</dc:date>
    </item>
  </channel>
</rss>

