cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-615040%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20calculer%20l'aire%20sous%20la%20courbe%20par%20int%C3%A9gration%20puis%20remplir%20le%20r%C3%A9sultat%20dans%20une%20nouvelle%20colonne.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-615040%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EEssayez%20de%20v%C3%A9rifier%20%C3%A0%20quoi%20ressemble%20la%20formule%20g%C3%A9n%C3%A9r%C3%A9e%20par%20JMP%2C%20elle%20remplacera%20tr%C3%A8s%20probablement%20votre%20heure%20par%26nbsp%3B%3A%20heure%2C%20utilisez%20donc%20un%20nom%20diff%C3%A9rent%20pour%20la%20variable%20et%20l'expression%20interne%20que%20les%20colonnes%20de%20votre%20table%20de%20donn%C3%A9es%20(et%20%C3%A9ventuellement%20encapsulez-la%20dans%20As%20Constant())%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EAs%20Constant(%0A%20resp%20%3D%20Expr(a%20*%20a)%3B%0A%20area%20%3D%20Integrate(resp%2C%20a%2C%20Col%20Min(%3Atime)%2C%20Col%20Max(%3Atime))%3B%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-615213%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20calculer%20l'aire%20sous%20la%20courbe%20par%20int%C3%A9gration%20puis%20remplir%20le%20r%C3%A9sultat%20dans%20une%20nouvelle%20colonne.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-615213%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EQue%20se%20passe-t-il%20si%20l'expression%20utilis%C3%A9e%20par%20Integrate%20doit%20%C3%AAtre%20extraite%20de%20la%20formule%20dans%20une%20colonne%2C%20par%20exemple%20pour%20Integrate%20en%20utilisant%20une%20formule%20%C3%A0%20partir%20d'un%20ajustement%20polynomial.%3C%2FP%3E%3CP%3EDans%20le%20tableau%20ci-dessous%2C%20la%20formule%20de%20la%20colonne%20pr%C3%A9dicteur%20utiliserait%20%3Atime%20et%20%3Aresponse.%20Existe-t-il%20une%20syntaxe%20rapide%20pour%20remplacer%20les%20noms%20de%20colonne%20par%20de%20nouvelles%20variables%26nbsp%3B%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F51369iE64A7D6BF48830D5%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22GroupSquareWolf_0-1679436129378.png%22%20alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-615282%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20calculer%20l'aire%20sous%20la%20courbe%20par%20int%C3%A9gration%20puis%20remplir%20le%20r%C3%A9sultat%20dans%20une%20nouvelle%20colonne.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-615282%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJe%20n'utiliserais%20pas%20de%20formules%20si%20vous%20voulez%20simplement%20r%C3%A9pliquer%20la%20m%C3%AAme%20valeur%20sur%20chaque%20ligne%20(dans%20la%20plupart%20des%20cas%2C%20il%20est%20pr%C3%A9f%C3%A9rable%20d'utiliser%20%26lt%3B%3CD%C3%89FINIR%20chaque%3D%22%22%20valeur%3D%22%22%20dans%3D%22%22%20des%3D%22%22%20cas%3D%22%22%20comme%3D%22%22%20celui-ci%3D%22%22%3E%0A%3C%2FD%C3%89FINIR%3E%3C%2FP%3E%3CP%3EJe%20ne%20sais%20pas%20s'il%20existe%20une%20syntaxe%20rapide%20pour%20remplacer%20les%20noms%20de%20colonnes%20par%20de%20nouvelles%20variables%2C%20mais%20char%2Bsubstitute%2Bparse%2Bexpressions%20est%20une%20option%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Adt%20%3D%20New%20Table(%22Untitled%22%2C%0A%20Add%20Rows(4)%2C%0A%20Compress%20File%20When%20Saved(1)%2C%0A%20New%20Column(%22t%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%22Best%22%2C%2012)%2C%20Set%20Values(%5B1%2C%202%2C%203%2C%204%5D))%2C%0A%20New%20Column(%22r%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%22Best%22%2C%2012)%2C%20Formula(%3At%20%5E%202))%0A)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22i%22%2C%20Numeric%2C%20Continuous%2C%20%26lt%3B%26lt%3B%20Set%20Each%20Value(%0A%20f%20%3D%20Eval%20Expr(Expr(Parse(Substitute(Char(Column(dt%2C%20%22r%22)%20%26lt%3B%26lt%3B%20get%20formula)%2C%20%22%3A%22%2C%20%22%22))))%3B%0A%20Integrate(f%2C%20t%2C%20Col%20Min(%3At)%2C%20Col%20Max(%3At))%3B%0A))%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-615023%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3Ecalculer%20l'aire%20sous%20la%20courbe%20par%20int%C3%A9gration%20puis%20renseigner%20le%20r%C3%A9sultat%20dans%20une%20nouvelle%20colonne.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-615023%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EDans%20cet%20exemple%20de%20table%20de%20donn%C3%A9es%2C%20la%20r%C3%A9ponse%20est%20d%C3%A9finie%20par%20la%20formule%26nbsp%3B%3A%20r%C3%A9ponse%20%3D%20heure*heure%3C%2FP%3E%3CP%3EJe%20voudrais%20calculer%20%22l'aire%20sous%20la%20courbe%22%20(AUC)%20par%20int%C3%A9gration%20en%20utilisant%20la%20formule%20d%C3%A9finie%20dans%20la%20colonne%20de%20r%C3%A9ponse%20et%20la%20plage%20de%20temps%20d%C3%A9finie%20dans%20la%20colonne%26nbsp%3B%3A%20temps%2C%20puis%20remplir%20le%20r%C3%A9sultat%20dans%20une%20nouvelle%20colonne%20de%20la%20table%20de%20donn%C3%A9es%20(par%20%22remplir%20%22%20Je%20veux%20dire%20que%20toutes%20les%20lignes%20ont%20la%20valeur%20de%20l'AUC%20calcul%C3%A9e).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJe%20sais%20que%20je%20peux%20utiliser%20le%20script%20suivant%20pour%20calculer%20l'AUC%2C%20et%20le%20r%C3%A9sultat%20de%20la%20zone%20est%2041333.%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eresp%20%3D%20Expr%20(time%20*%20time)%3B%0A%0Aarea%20%3D%20Integrate%20(resp%2C%20time%2C%2010%2C%2050)%3B%0A%0Ashow%20(area)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3ECependant%2C%20lorsque%20j'ai%20essay%C3%A9%20de%20remplir%20le%20r%C3%A9sultat%20AUC%20(toutes%20les%20lignes%20ont%20la%20valeur%2041333)%3CSPAN%3E%20dans%20la%20colonne%20%3AInt%C3%A9grer%3C%2FSPAN%3E%3CSPAN%3E%20en%20utilisant%20la%20formule%20%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EInt%C3%A9grer(%20%3Aresponse%2C%20%3Atime%2C%20Col%20Maximum(%20%3Atime%20)%2C%20Col%20Minimum(%20%3Atime%20)%20)%3C%2FP%3E%3CP%3Eau%20lieu%20de%20remplir%20le%20r%C3%A9sultat%2041333%20%2C%20la%20formule%20a%20calcul%C3%A9%20le%20r%C3%A9sultat%20en%20fonction%20de%20la%20valeur%20d%C3%A9finie%20de%20%3A%20time%20dans%20chaque%20ligne.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EQuelle%20est%20la%20bonne%20fa%C3%A7on%20d'%C3%A9crire%20la%20formule%20pour%20que%20la%20colonne%20%3AIntegrate%20soit%20remplie%20avec%20le%20r%C3%A9sultat%2041333%26nbsp%3B%3F%3C%2FP%3E%3CP%3EJe%20sais%20que%20je%20pourrais%20utiliser%20JSL%20pour%20cr%C3%A9er%20une%20nouvelle%20table%20de%20donn%C3%A9es%2C%20puis%20joindre%20le%20r%C3%A9sultat%2C%20mais%20je%20pr%C3%A9f%C3%A9rerais%20le%20faire%20dans%20la%20m%C3%AAme%20table%20de%20donn%C3%A9es.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMerci!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22GroupSquareWolf_0-1679416641928.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679416641928.png%22%20style%3D%22width%3A%20293px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679416641928.png%22%20style%3D%22width%3A%20293px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F51343i47B15125FBF81FE5%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22GroupSquareWolf_0-1679416641928.png%22%20alt%3D%22GroupSquareWolf_0-1679416641928.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-615023%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EAutomatisation%20et%20script%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Choose Language Hide Translation Bar
GroupSquareWolf
Level III

calculate area under the curve by integration then populate the result in a new column.

In this example datatable, response is defined by fomula:  response = time*time

I would like to calculate "area under the curve" (AUC) by integration using the fomula defined in the response column and the time range defined in the :time column, then populate the result in a new column in the datatable (by "populate" I mean all rows have the value of the calculated AUC).

 

I know I can use the following script to calculate the AUC, and the result of area is 41333.

resp = Expr (time * time);

area = Integrate (resp, time, 10, 50);

show (area);

However, when I tried to populate the AUC result (all rows have the value of 41333) in the :Integrate column by using formula: 

      Integrate( :response, :time, Col Maximum( :time ), Col Minimum( :time ) )

instead of populating the result 41333 , the formula calculated the result based on the defined value of : time in each row. 

 

What is the correct way to write the formula so that the :Integrate column is populated with the result 41333?

I know I could use JSL to create a new datatable and then join the result but would prefer to do this within the same datatable.

 

Thanks!

 

GroupSquareWolf_0-1679416641928.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: calculate area under the curve by integration then populate the result in a new column.

I wouldn't use formulas if you just want to replicate same value to each row (in most cases it is better to use << Set Each Value in cases like this).

I'm not sure if there is any quick syntax to replace column names with new variables, but char+substitute+parse+expressions is one option

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(4),
	Compress File When Saved(1),
	New Column("t", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4])),
	New Column("r", Numeric, "Continuous", Format("Best", 12), Formula(:t ^ 2))
);

dt << New Column("i", Numeric, Continuous, << Set Each Value(
	f = Eval Expr(Expr(Parse(Substitute(Char(Column(dt, "r") << get formula), ":", ""))));
	Integrate(f, t, Col Min(:t), Col Max(:t));
));
-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: calculate area under the curve by integration then populate the result in a new column.

Try checking out how the formula JMP generates does look like, it will most likely replace your time with :time so use different name for the variable and inside expression than columns in your data table (and possibly wrap it inside As Constant())

As Constant(
	resp = Expr(a * a);
	area = Integrate(resp, a, Col Min(:time), Col Max(:time));
)
-Jarmo
GroupSquareWolf
Level III

Re: calculate area under the curve by integration then populate the result in a new column.

What if the expression used by Integrate needs to be extracted from the formula in a column, for example to Integrate using a formula from a polynomial fit.

In the table below, the formula in the predictor column would use  :time and :response. Is there a quick syntax to replace the column names with new variables?

 

GroupSquareWolf_0-1679436129378.png

 

jthi
Super User

Re: calculate area under the curve by integration then populate the result in a new column.

I wouldn't use formulas if you just want to replicate same value to each row (in most cases it is better to use << Set Each Value in cases like this).

I'm not sure if there is any quick syntax to replace column names with new variables, but char+substitute+parse+expressions is one option

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(4),
	Compress File When Saved(1),
	New Column("t", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4])),
	New Column("r", Numeric, "Continuous", Format("Best", 12), Formula(:t ^ 2))
);

dt << New Column("i", Numeric, Continuous, << Set Each Value(
	f = Eval Expr(Expr(Parse(Substitute(Char(Column(dt, "r") << get formula), ":", ""))));
	Integrate(f, t, Col Min(:t), Col Max(:t));
));
-Jarmo