<?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 Convert all radians columns to degrees in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Convert-all-radians-columns-to-degrees/m-p/835080#M101291</link>
    <description>&lt;P&gt;I need a JSL loop that will search the column headers of a data table, and if the column header has "(rad)" in it, I'd like to multiply all of the values in that column by 180/pi, and then change "(rad)" to "(deg)" in the column header.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried everything I can think of -- including chatGPT -- but so far no luck.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Feb 2025 23:55:15 GMT</pubDate>
    <dc:creator>BHarris</dc:creator>
    <dc:date>2025-02-03T23:55:15Z</dc:date>
    <item>
      <title>Convert all radians columns to degrees</title>
      <link>https://community.jmp.com/t5/Discussions/Convert-all-radians-columns-to-degrees/m-p/835080#M101291</link>
      <description>&lt;P&gt;I need a JSL loop that will search the column headers of a data table, and if the column header has "(rad)" in it, I'd like to multiply all of the values in that column by 180/pi, and then change "(rad)" to "(deg)" in the column header.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried everything I can think of -- including chatGPT -- but so far no luck.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 23:55:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Convert-all-radians-columns-to-degrees/m-p/835080#M101291</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2025-02-03T23:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert all radians columns to degrees</title>
      <link>https://community.jmp.com/t5/Discussions/Convert-all-radians-columns-to-degrees/m-p/835138#M101294</link>
      <description>&lt;OL&gt;
&lt;LI&gt;Get all columns using &amp;lt;&amp;lt; Get Column Names&lt;/LI&gt;
&lt;LI&gt;Set table to not update using &amp;lt;&amp;lt; begin data update&lt;/LI&gt;
&lt;LI&gt;Loop over them using For Each&lt;/LI&gt;
&lt;LI&gt;Check if their name has (rad) in it using Contains / Starts With / Ends With&lt;/LI&gt;
&lt;LI&gt;Use For Each Row to loop over it and change the values to degrees
&lt;OL&gt;
&lt;LI&gt;I would hope there was better method for this, but I'm not sure if there really is unless you wish to create new columns and delete old as&lt;STRONG&gt; we shouldn't use&lt;/STRONG&gt; &amp;lt;&amp;lt; set each value which makes to extremely easy to do and read&lt;/LI&gt;
&lt;LI&gt;Apply Formula in place (added in JMP18) might work but it is difficult to understand how to use it&lt;/LI&gt;
&lt;LI&gt;Using matrix values is one good option but For Each Row will work always, always good idea to learn it&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;Use substitute and &amp;lt;&amp;lt; Set Name to rename the column&lt;/LI&gt;
&lt;LI&gt;let table update again using &amp;lt;&amp;lt; end data update&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(2),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([., .])),
	New Column("a (rad)", Numeric, "Continuous", Format("Best", 12), Set Values([1, .]))
);

colnames = dt &amp;lt;&amp;lt; Get Column Names(Continuos, "String");

dt &amp;lt;&amp;lt; Begin Data Update();
For Each({colname}, colnames,
	If(Contains(colname, "(rad)"),
		For Each Row(dt, Column(dt, colname)[] = Column(dt, colname)[] * 180 / Pi());
		Column(dt, colname) &amp;lt;&amp;lt; Set Name(Substitute(colname, "(rad)", "(deg)"));
	)
);
dt &amp;lt;&amp;lt; End Data Update();

Write();
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Feb 2025 05:28:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Convert-all-radians-columns-to-degrees/m-p/835138#M101294</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-04T05:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Convert all radians columns to degrees</title>
      <link>https://community.jmp.com/t5/Discussions/Convert-all-radians-columns-to-degrees/m-p/835985#M101313</link>
      <description>&lt;P&gt;Always impressive, thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A few follow-on questions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Why is "colname" in curly braces as the first argument of the for each loop?&lt;/LI&gt;&lt;LI&gt;I was trying to do something like "dt:colname[rowIdx] =&amp;nbsp;dt:colname[rowIdx] * 180/Pi()" -- how would JMP interpreting this line and why is it wrong?&lt;/LI&gt;&lt;LI&gt;What does the "[]" do at the end of "Column(dt,colname)[]"?&amp;nbsp; Is there a section of the documentation that discusses this construct?&amp;nbsp;&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 07:01:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Convert-all-radians-columns-to-degrees/m-p/835985#M101313</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2025-02-05T07:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Convert all radians columns to degrees</title>
      <link>https://community.jmp.com/t5/Discussions/Convert-all-radians-columns-to-degrees/m-p/835995#M101314</link>
      <description>&lt;OL&gt;
&lt;LI&gt;It is the syntax for For Each.&amp;nbsp;&lt;A href="https://www.jmp.com/support/help/en/18.1/#page/jmp/conditional-and-logical-functions.shtml?os=win&amp;amp;source=application#ww10169967" target="_blank"&gt;Conditional and Logical Functions&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Most likely JMP won't be able to interpret anything from that as it doesn't find colname column from your data table as colname just stores the value. I think you could use As Column instead of Column()[] and it might work
&lt;PRE&gt;&lt;EM&gt;As Column(dt, colname) = As Column(dt, colname) * 180 / Pi()&lt;/EM&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;[] is same as [Row()] and it is used to access current row when using Column(). &lt;A href="https://www.jmp.com/support/help/en/18.1/#page/jmp/iterate-on-rows-in-a-table.shtml#" target="_blank"&gt;Iterate on Rows in a Table&lt;/A&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 05 Feb 2025 08:05:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Convert-all-radians-columns-to-degrees/m-p/835995#M101314</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-05T08:05:41Z</dc:date>
    </item>
  </channel>
</rss>

