cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
winfried_theis
Level II

How to retrieve group names from by-group objects?

Dear all,

I just try to get my head around access to by group object list and how to access them. I wrote a nice little program that runs a bubble plot by country and as it is a moving one I want to save it as SWF. All this shall become a regular report so I want to automate the filename assigned. As the filename I want to have Country_date_otherparameterfromprogram.swf. Date and the other parameters are easy, the problem is to know the order of the bubbleplots in the list created by JMP. As an R user I was first looking for a function like str() which in R returns an overview of the object telling you the names of each sub-object in the list plus the first few values of the subobject. Failing to find such a function I tried to use the "show tree structure" but looking at the output of it I could see the Countryname I was looking for, but still I cannot access it.

I tried:

bubble=dt<<bubble plot(..., by(:Country));

bubble[1][outline box(1)];

and a couple of other things like sending "get name" to the object.

Cheers,

Winfried

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: How to retrieve group names from by-group objects?

Hi Winfried,

You can get the titles of the outline nodes in the reports and parse them to get the by group values from them. The Get Title message may be what you're looking for.

Here's an example.


Open( "$SAMPLE_DATA/SATByYear.jmp" );



bubbles = Bubble Plot(


  X( :SAT Math ),


  Y( :SAT Verbal ),


  Sizes( :Name( "% Taking (2004)" ) ),


  ID( :State ),


  All Labels( 1 ),


  by( :Region, year )


);



bygroups = {};



For( i = 1, i <= N Items( bubbles ), i++,


  title = (Report( bubbles[i] )[Outline Box( 1 )]) << get title;


  bygroup = Word( -1, Word( 1, title, "," ) ) || "," ||


  Word( 2, title, "," );


  Insert Into( bygroups, bygroup );


);



Show( bygroups );



-Jeff

-Jeff

View solution in original post

4 REPLIES 4
David_Burnham
Super User (Alumni)

Re: How to retrieve group names from by-group objects?

The By Group qualifier results in multiple objects being created for example:

Open("$SAMPLE_DATA/Big Class.jmp")

bp = BubblePlot( X( :height ),Y( :weight ),By(:sex));

show(bp);

bp = {Bubble Plot[], Bubble Plot[]};

So bp is a list of objects, each of which receives data just for one level of the grouping variable. As far as the bubbleplot is concerned its got the data and plots it - it doesn't know about grouping i.e. we can't send a message to it << Get Group Name.

So to get the group name, we need to get the levels that JMP used to generate each of the plots.  You can use the summarise command to do this.  For the above example:

summarize(byValues=by(:sex));

show(byValues);

So for this example we have 2 bubbleplots bp[1] and bp[2].

The grouping variable for the first plot is byValues[1] and the grouping variable for the 2nd is byValues[2].

Dave

-Dave
winfried_theis
Level II

Re: How to retrieve group names from by-group objects?


Hi Dave,

thanks for your answer!

I went the way you describe after I could not figure out the way to retrieve something from the objects. I just had had the hope one could access in some way the title (or other element) of the byGroup listelement as e.g. in my example the title of bp[1] of course contains the byLevel[1] as title. The reason for asking is, if you got more than one BY variable things might quickly get tricky in sussing out which element is which. Ie. which by variable goes first, which second and in which order are the levels actually.

Cheers,

Winfried

Jeff_Perkinson
Community Manager Community Manager

Re: How to retrieve group names from by-group objects?

Hi Winfried,

You can get the titles of the outline nodes in the reports and parse them to get the by group values from them. The Get Title message may be what you're looking for.

Here's an example.


Open( "$SAMPLE_DATA/SATByYear.jmp" );



bubbles = Bubble Plot(


  X( :SAT Math ),


  Y( :SAT Verbal ),


  Sizes( :Name( "% Taking (2004)" ) ),


  ID( :State ),


  All Labels( 1 ),


  by( :Region, year )


);



bygroups = {};



For( i = 1, i <= N Items( bubbles ), i++,


  title = (Report( bubbles[i] )[Outline Box( 1 )]) << get title;


  bygroup = Word( -1, Word( 1, title, "," ) ) || "," ||


  Word( 2, title, "," );


  Insert Into( bygroups, bygroup );


);



Show( bygroups );



-Jeff

-Jeff
winfried_theis
Level II

Re: How to retrieve group names from by-group objects?


Hi Jeff,

thanks this is exactly what I was looking for! Still takes a bit getting used to the structures in JMP, but I guess I'm getting there...

Cheers,

Winfried