cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
hogi
Level XII

manual grouping - extended version?

The function Rows / Row Selection / Name Selection in Colum is very useful.

 

You can specify a label for the selected and the unselected rows.

HolgerSp_0-1662193815636.png

 

The best feature of the function
You can leave an entry empty - then you can write again and again into the same column and collect infos, like grades for studens in the first example.

If you changed your mind, you can also over-ride previous entires.

 

So, the standard behaviour of the function is:

- just do something if the user entered a value

- default action: override the previous entry.

 

Unfortunately, the function can just be used for disjunct groups, like grades.
I would like to use the function to collect infos about interesting samples.

For the Big Class Example you could think about sports activities, like in the second example

(here the JSL code, in reality you would go to the menu and open the dialog box )

 

A problem arises if a student is in 2 teams -  then the last call of the function overwrides the entry of the previous one.

Is there some Shift-Click extended version of the function that enables alternative actions like:

- append (perhaps with a clever way to put the commas

- prepend 

- delete  ?

 

Example1: grades

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

dt << Clear Select << Select Rows( [2, 4, 8, 9, 20, 25, 26, 35, 36] );
wait(2);
dt << Name Selection in Column( Column Name( "grade" ), Selected( "A" ) );
wait(2);
dt<< Clear Select <<Select Rows( [ 14, 17, 18, 19, 23, 31,  38] );
wait(1);
dt <<Name Selection in Column( Column Name( "grade" ), Selected( "B" ) );
wait(1);
dt << Clear Select <<Select Rows( [3, 5, 6, 15, 16, 21, 27, 29, 33, 34, 39, 40] );
wait(1);
dt << Name Selection in Column( Column Name( "grade" ), Selected( "C" ) );
wait(1);
Data Table( "Big Class" ) << Select Where( :grade == "" );
wait(1);
dt << Name Selection in Column( Column Name( "grade" ), Selected( "D" ) );
wait(2);

//change grade;
dt << Clear Select <<Select Rows( [12] );
wait(2);
dt << Name Selection in Column( Column Name( "grade" ), Selected( "A" ) );

 

Example2: sports activities (unfortunately, append=1 doesn't work)

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column("activity", Character, "Multiple Response");

dt << Clear Select << Select Rows( [2, 4, 8, 9, 20, 25, 26, 35, 36] );
wait(2);
dt << Name Selection in Column( Column Name( "activity" ), Selected( " ,football" ) );
wait(2);
dt << Clear Select << Select Rows( [2, 4, 8, 12, 22, 27, 28, 29, 30] );
wait(1);
dt <<Name Selection in Column( Column Name( "activity" ), Selected( ", Tennis" ), Append=1 );

 

 

7 REPLIES 7
jthi
Super User

Re: manual grouping - extended version?

I think there are no such extensions, but you could write your own function(s)

Names Default To Here(1);

append_to_selected_rows = function({dt, col_name, new_val, separator = ","}, {Default Local},
	sel_rows = dt << Get Selected Rows;
	old_rows = dt[sel_rows, "activity"];
	new_rows = Transform Each({old_row}, old_rows,
		If(Is Missing(old_row),
			new_val
		,
			old_row || separator || new_val
		);
	);
	dt[sel_rows, "activity"] = new_rows;
);

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column("activity", Character, "Multiple Response");

wait(1);
dt << Clear Select << Select Rows( [2, 4, 8, 9, 20, 25, 26, 35, 36] );
wait(1);
append_to_selected_rows(dt, "activity", "football");

wait(1);
dt << Clear Select << Select Rows( [2, 4, 8, 12, 22, 27, 28, 29, 30] );
wait(1);
append_to_selected_rows(dt, "activity", "Tennis");

 

-Jarmo
hogi
Level XII

Re: manual grouping - extended version?

Hi Jarmo.

 

Thanks for the JSL code.

... and for the opinion: not possible (yet) via JMP GUI.

 

-> I created a wish to enable Name Selection in Column to handle such multiple response information.

https://community.jmp.com/t5/JMP-Wish-List/Name-Selection-in-Column-extended-options/idi-p/540229

Let's see if there is more interest ...

hogi
Level XII

Re: manual grouping - extended version?

As the wish was rejected today, I took Jarmo's code and generated my  universal "label" function
You can put it into a toolbar or link it to a keyboard shortcut.
Then you can iteratively selected rows, run the script and label the selected columns.
Previous labels will no longer be deleted.

Then the label column can be used for exclusion and highlighting ... and to keep track of the idea behind the decision ...

Less drastic than nuking the rows out
https://community.jmp.com/t5/Discovery-Summit-Americas-2022/Stay-in-the-Flow-With-Custom-Scripts-and...


Names Default To Here(1);

dt = Current Data Table();
colNames=dt << get column names ();
If( !Contains( dt << get column names( string ), "Label" ),
dt << New Column("Label", Character, "Multiple Response"));

sel_rows = dt << Get Selected Rows;
If(Nitems(sel_rows),
If(
	ex = New Window( "label rows",
		<<Modal,
		<<Return Result,
		V List Box(
			H List Box( "Enter label", variable =  Text Edit Box( "selected", Set Width(200) ) ),
			H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )
		)
	);
	ex["button"] == 1;
,
	new_val= ex["variable"];
	
	old_rows = dt[sel_rows, "Label"];
	new_rows = Transform Each({old_row}, old_rows,
		If(Is Missing(old_row),
			new_val
		,
			old_row || ", " || new_val
		);
	);
	dt[sel_rows, "Label"] = new_rows;
	,
	"CANCEL"
),"CANCEL");
hogi
Level XII

Re: manual grouping - extended version?

Is there a list of plots and report types that support "splitting" of multiple response column entries like "Distribution" does?

HolgerSp_0-1664212339520.png               HolgerSp_1-1664212357150.png

HolgerSp_2-1664212521034.png

 

 

 

 

 

jthi
Super User

Re: manual grouping - extended version?

I'm not sure if there is such a list, but JMP17 will add support for Graph Builder (New in JMP17).

-Jarmo
hogi
Level XII

Re: manual grouping - extended version?

sounds promising
Will there be an option to toggle between "raw" and "split" mode?

 

I am not yet sure what's the best way to use the "label".
Use it as overlay or color would be the first choice, but they are needed to show the actual information of the plot.
So, perhaps "page"  - or groupX ...

hogi
Level XII

Re: manual grouping - extended version?

another thing:
I think it's a good idea to auto-activate NewFormulaColumn/"group by" for the label column.
Is there a jsl code to do so?
Unfortunately, the advanced log doesn't record this action and the new formula column menu doesn't shop up in the Menus and Toolbars dialogue.

HolgerSp_0-1664259604568.png