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
Choose Language Hide Translation Bar
Ake
Ake
Level III

Script for Group by and Fit each value

I have a script in the Custom toolbar that turns character columns into numeric, which I use all the time.

I also use Group by and Fit each value whenever I have a suitable graph ready.

 

Now I want a script that, when I already have an x-y graph, does Group by and Fit each value. The below script works as I tried it on Big Class.jmp, but I want it to do just the Group by and Fit each value, on an already existing graph. I guess I need to define obj so that it points to the graph, but how?

 

Names Default To Here(1);
dt = Current Data Table();

obj = dt << Bivariate(Y(:Weight), X(:Height));
obj << Group By(:Sex);
obj << Fit Each Value;

 

 
 

Ake_0-1700591711105.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Script for Group by and Fit each value

Depending on how robust script you want and with what type of reports you want it to work with, you might have to modify this

Names Default To Here(1);

rep = Current Report();
obj = rep[OutlineBox(1)] << Get Scriptable Object;
// might have to add check if you have correct type of report open

obj << Group By(:Sex);
obj << Fit Each Value;
-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Script for Group by and Fit each value

Depending on how robust script you want and with what type of reports you want it to work with, you might have to modify this

Names Default To Here(1);

rep = Current Report();
obj = rep[OutlineBox(1)] << Get Scriptable Object;
// might have to add check if you have correct type of report open

obj << Group By(:Sex);
obj << Fit Each Value;
-Jarmo
Ake
Ake
Level III

Re: Script for Group by and Fit each value

Appears to work wonderfully! Thanks a lot!

Ake
Ake
Level III

Re: Script for Group by and Fit each value

Give me the little finger and I'll take the hand! That worked so good, that now I would like the same thing to work when I have more than one plot in the report, e.g. when I have plotted more than one parameter or by group. Tried experimenting with 'xPath' that I found in the forum, but no success. Syntax is everything.

 

Ake_0-1700738060945.png

 

jthi
Super User

Re: Script for Group by and Fit each value

Send << get xml message to your object reference (rep in this case). Then from log try to see if there is something what you could use to get access to correct outlineboxes

jthi_0-1700738625547.png

If you have JMP17 I think helpKey is usually quite good bet. You could also possibly use outlinebox names.

 

After you have those outlinebox references, modify script as needed

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt = Fit Group(
	Bivariate(Y(:height), X(:age)),
	Bivariate(Y(:weight), X(:age)),
	<<{Arrange in Rows(1)}
);

rep = Current Report();

obs = rep << XPath("//OutlineBox[@helpKey = 'Bivariate Report']");
objs = obs << Get Scriptable Object;
// might have to add check if you have correct type of report open

objs << Group By(:Sex);
objs << Fit Each Value;
-Jarmo